Skip to content

Instantly share code, notes, and snippets.

@jkhaui
Created January 21, 2019 03:32
Show Gist options
  • Save jkhaui/6cfa9e12a3b321728f68e4cd2765e33d to your computer and use it in GitHub Desktop.
Save jkhaui/6cfa9e12a3b321728f68e4cd2765e33d to your computer and use it in GitHub Desktop.
import graphene
class Query(graphene.ObjectType):
hello = graphene.String(name=graphene.Argument(
graphene.String, default_value="stranger"), age=graphene.Argument(graphene.Int))
def resolve_hello(self, args, context, info):
return 'Hello {} you are {} years old'.format(args['name'], args['age'])
def main():
schema = graphene.Schema(query=Query)
result = schema.execute('{ hello(name: "bob", age: 13) }')
print(result.data['hello'])
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment