2016-09-20 08:04:23 +03:00
|
|
|
import graphene
|
2016-09-20 08:15:10 +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
|
|
|
|
2016-09-20 08:04:23 +03:00
|
|
|
def resolve_thrower(self, args, context, info):
|
|
|
|
raise Exception("Throws!")
|
2016-09-20 08:15:10 +03:00
|
|
|
|
2016-09-20 08:04:23 +03:00
|
|
|
def resolve_request(self, args, context, info):
|
|
|
|
request = context
|
|
|
|
return request.GET.get('q')
|
|
|
|
|
|
|
|
def resolve_test(self, args, context, info):
|
|
|
|
return 'Hello %s' % (args.get('who') or 'World')
|
|
|
|
|
|
|
|
|
|
|
|
class MutationRoot(ObjectType):
|
|
|
|
write_test = graphene.Field(QueryRoot)
|
|
|
|
|
|
|
|
def resolve_write_test(self, args, context, info):
|
|
|
|
return QueryRoot()
|
|
|
|
|
|
|
|
|
|
|
|
schema = Schema(query=QueryRoot, mutation=MutationRoot)
|