graphene-django/graphene_django/tests/schema_view.py

32 lines
812 B
Python
Raw Normal View History

import graphene
2017-07-28 19:43:27 +03:00
from graphene import ObjectType, Schema
from .mutations import PetFormMutation, PetMutation
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):
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")
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")
class MutationRoot(ObjectType):
pet_form_mutation = PetFormMutation.Field()
pet_mutation = PetMutation.Field()
write_test = graphene.Field(QueryRoot)
2017-07-28 19:43:27 +03:00
def resolve_write_test(self, info):
return QueryRoot()
schema = Schema(query=QueryRoot, mutation=MutationRoot)