graphene-django/graphene_django/tests/schema.py

39 lines
734 B
Python
Raw Normal View History

import graphene
from graphene import Schema, relay
from ..types import DjangoObjectType
from .models import Article, Reporter
class Character(DjangoObjectType):
class Meta:
model = Reporter
2018-07-20 02:51:33 +03:00
interfaces = (relay.Node,)
2017-07-28 19:43:27 +03:00
def get_node(self, info, id):
pass
class Human(DjangoObjectType):
raises = graphene.String()
class Meta:
model = Article
2018-07-20 02:51:33 +03:00
interfaces = (relay.Node,)
2017-07-28 19:43:27 +03:00
def resolve_raises(self, info):
raise Exception("This field should raise exception")
2017-07-28 19:43:27 +03:00
def get_node(self, info, id):
pass
class Query(graphene.ObjectType):
human = graphene.Field(Human)
2017-07-28 19:43:27 +03:00
def resolve_human(self, info):
return Human()
schema = Schema(query=Query)