graphene/tests/contrib_django/test_urls.py

38 lines
692 B
Python
Raw Normal View History

2015-10-03 23:27:19 +03:00
from django.conf.urls import url
2015-10-11 00:53:46 +03:00
import graphene
2015-10-03 23:27:19 +03:00
from graphene import Schema
from graphene.contrib.django.types import DjangoNode
from graphene.contrib.django.views import GraphQLView
2015-10-03 23:27:19 +03:00
from .models import Article, Reporter
2015-10-03 23:27:19 +03:00
class Character(DjangoNode):
2015-10-03 23:27:19 +03:00
class Meta:
model = Reporter
def get_node(self, id):
pass
class Human(DjangoNode):
2015-10-11 00:53:46 +03:00
raises = graphene.StringField()
2015-10-03 23:27:19 +03:00
class Meta:
model = Article
2015-10-11 00:53:46 +03:00
def resolve_raises(self, *args):
raise Exception("This field should raise exception")
2015-10-03 23:27:19 +03:00
def get_node(self, id):
pass
schema = Schema(query=Human)
urlpatterns = [
url(r'^graphql', GraphQLView.as_view(schema=schema)),
]