File: schema.py

package info (click to toggle)
django-graphene 3.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 8,996 kB
  • sloc: javascript: 25,534; python: 11,992; makefile: 233; sh: 4
file content (40 lines) | stat: -rw-r--r-- 788 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import graphene
from graphene import Schema, relay

from ..types import DjangoObjectType
from .models import Article, Reporter


class Character(DjangoObjectType):
    class Meta:
        model = Reporter
        interfaces = (relay.Node,)
        fields = "__all__"

    def get_node(self, info, id):
        pass


class Human(DjangoObjectType):
    raises = graphene.String()

    class Meta:
        model = Article
        interfaces = (relay.Node,)
        fields = "__all__"

    def resolve_raises(self, info):
        raise Exception("This field should raise exception")

    def get_node(self, info, id):
        pass


class Query(graphene.ObjectType):
    human = graphene.Field(Human)

    def resolve_human(self, info):
        return Human()


schema = Schema(query=Query)