2015-11-20 03:19:22 +03:00
|
|
|
import graphene
|
|
|
|
|
2015-11-20 03:47:10 +03:00
|
|
|
|
2015-11-20 08:25:18 +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)
|
2015-11-20 03:55:32 +03:00
|
|
|
print(result.data['patron'])
|