Created
January 21, 2019 03:32
-
-
Save jkhaui/6cfa9e12a3b321728f68e4cd2765e33d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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