graphql

GraphQL tutorial with Python (`graphene`)

Original source I followed the linke below. https://hatemtayeb2.medium.com/hello-graphql-a-practical-guide-a2f7f9f70ab4 Install library pip -U install graphene Use it scheme.py import graphene import json class Query(graphene.ObjectType): hello = graphene.String() def resolve_hello(self, info): return "world" schema = graphene.Schema(query=Query) result = schema.execute( ''' { hello } ''' ) data = dict(result.data.items()) print(json.dumps(data,indent=2)) Try the code. $ python schema.py { "hello": "world" } GraphQL concepts Every GraphQL implementation needs a Query class that contains some fields, every field (not always) must have a resolver function that return data related to the field.