DEV Community

Discussion on: Snapshot Testing in Python

Collapse
 
mikerossi profile image
Mike-Rossi

Hello,

In the last image, you have the line client = Client(my_schema), what exactly would go into my_schema, would it be the name of your schema file or would it be the query code itself?

Collapse
 
leahein profile image
Leah Einhorn

Ah, it would be the GraphQL schema object. The example provided assumes usage of graphene, so the following would be a simple example of the schema:

from graphene import ObjectType, String, Schema

class Query(ObjectType):

    hello = String()

    def resolve_hello(root, info, name):
        return f'Hello {name}!'

my_schema = Schema(query=Query)

You would then pass my_schema into the Client.

You can read more about graphene here.