2016-06-22 09:56:38 +03:00
|
|
|
import graphene
|
|
|
|
from graphene import Schema
|
|
|
|
from ..types import DjangoNode, DjangoObjectType
|
|
|
|
|
|
|
|
from .models import Article, Reporter
|
|
|
|
|
|
|
|
|
2016-08-14 20:57:08 +03:00
|
|
|
class Character(DjangoObjectType):
|
2016-06-22 09:56:38 +03:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Reporter
|
2016-08-14 20:57:08 +03:00
|
|
|
interfaces = (DjangoNode, )
|
2016-06-22 09:56:38 +03:00
|
|
|
|
|
|
|
def get_node(self, id, context, info):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2016-08-14 20:57:08 +03:00
|
|
|
class Human(DjangoObjectType):
|
2016-06-22 09:56:38 +03:00
|
|
|
raises = graphene.String()
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = Article
|
2016-08-14 20:57:08 +03:00
|
|
|
interfaces = (DjangoNode, )
|
2016-06-22 09:56:38 +03:00
|
|
|
|
|
|
|
def resolve_raises(self, *args):
|
|
|
|
raise Exception("This field should raise exception")
|
|
|
|
|
|
|
|
def get_node(self, id):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
class Query(graphene.ObjectType):
|
|
|
|
human = graphene.Field(Human)
|
|
|
|
|
|
|
|
def resolve_human(self, args, context, info):
|
|
|
|
return Human()
|
|
|
|
|
|
|
|
|
|
|
|
schema = Schema(query=Query)
|