2016-09-20 08:04:23 +03:00
|
|
|
import graphene
|
2017-07-28 19:43:27 +03:00
|
|
|
from graphene import ObjectType, Schema
|
2016-09-20 08:04:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
class QueryRoot(ObjectType):
|
|
|
|
|
|
|
|
thrower = graphene.String(required=True)
|
|
|
|
request = graphene.String(required=True)
|
|
|
|
test = graphene.String(who=graphene.String())
|
2016-09-20 08:15:10 +03:00
|
|
|
|
2017-07-28 19:43:27 +03:00
|
|
|
def resolve_thrower(self, info):
|
2016-09-20 08:04:23 +03:00
|
|
|
raise Exception("Throws!")
|
2016-09-20 08:15:10 +03:00
|
|
|
|
2017-07-28 19:43:27 +03:00
|
|
|
def resolve_request(self, info):
|
|
|
|
return info.context.GET.get('q')
|
2016-09-20 08:04:23 +03:00
|
|
|
|
2017-07-28 19:43:27 +03:00
|
|
|
def resolve_test(self, info, who=None):
|
2017-07-25 08:27:50 +03:00
|
|
|
return 'Hello %s' % (who or 'World')
|
2016-09-20 08:04:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
class MutationRoot(ObjectType):
|
|
|
|
write_test = graphene.Field(QueryRoot)
|
|
|
|
|
2017-07-28 19:43:27 +03:00
|
|
|
def resolve_write_test(self, info):
|
2016-09-20 08:04:23 +03:00
|
|
|
return QueryRoot()
|
|
|
|
|
|
|
|
|
|
|
|
schema = Schema(query=QueryRoot, mutation=MutationRoot)
|