graphene/examples/simple_example.py

28 lines
475 B
Python
Raw Normal View History

2015-11-20 03:19:22 +03:00
import graphene
2015-11-20 03:47:10 +03:00
class Patron(graphene.ObjectType):
id = graphene.ID()
2015-11-20 03:19:22 +03:00
name = graphene.String()
age = graphene.ID()
2015-11-20 03:47:10 +03:00
2015-11-20 03:19:22 +03:00
class Query(graphene.ObjectType):
patron = graphene.Field(Patron)
def resolve_patron(self, args, info):
return Patron(id=1, name='Demo')
schema = graphene.Schema(query=Query)
query = '''
query something{
patron {
id
name
}
2015-11-23 04:29:30 +03:00
}
2015-11-20 03:19:22 +03:00
'''
result = schema.execute(query)
print(result.data['patron'])