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
|
|
|
|
2020-12-31 02:37:57 +03:00
|
|
|
from .mutations import PetFormMutation, PetMutation
|
|
|
|
|
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):
|
2018-07-20 02:51:33 +03:00
|
|
|
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):
|
2018-07-20 02:51:33 +03:00
|
|
|
return "Hello %s" % (who or "World")
|
2016-09-20 08:04:23 +03:00
|
|
|
|
|
|
|
|
|
|
|
class MutationRoot(ObjectType):
|
2020-12-31 02:37:57 +03:00
|
|
|
pet_form_mutation = PetFormMutation.Field()
|
|
|
|
pet_mutation = PetMutation.Field()
|
2016-09-20 08:04:23 +03:00
|
|
|
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)
|