Add new class instead of dict
This commit is contained in:
parent
6e1501f33b
commit
775bff5c1b
|
|
@ -6,6 +6,10 @@ from graphene_django.filter import DjangoFilterConnectionField
|
|||
from books.models import Topic, Module
|
||||
from books.schema.nodes import ModuleNode
|
||||
|
||||
class NotFoundFailure:
|
||||
reason = 'Not Found'
|
||||
|
||||
|
||||
NOT_FOUND = { 'reason': 'Not Found'}
|
||||
|
||||
class NotFound(graphene.ObjectType):
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@ from graphene_django.filter import DjangoFilterConnectionField
|
|||
from api.utils import get_object
|
||||
from core.logger import get_logger
|
||||
from .connections import TopicConnection, ModuleConnection
|
||||
from .nodes import ContentBlockNode, ChapterNode, ModuleNode, NOT_FOUND, TopicNode, SnapshotNode, TopicOr404Node
|
||||
from .nodes import ContentBlockNode, ChapterNode, ModuleNode, NOT_FOUND, NotFoundFailure, TopicNode, SnapshotNode, \
|
||||
TopicOr404Node
|
||||
from ..models import Book, Topic, Module, Chapter, Snapshot
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
|
@ -66,5 +67,5 @@ class BookQuery(object):
|
|||
try:
|
||||
return Topic.objects.get(slug=slug)
|
||||
except Topic.DoesNotExist:
|
||||
return NOT_FOUND
|
||||
return NotFoundFailure
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -702,6 +702,10 @@ interface Node {
|
|||
id: ID!
|
||||
}
|
||||
|
||||
type NotFound {
|
||||
reason: String
|
||||
}
|
||||
|
||||
type NoteNode implements Node {
|
||||
id: ID!
|
||||
text: String!
|
||||
|
|
@ -852,7 +856,7 @@ type Query {
|
|||
assignment(id: ID!): AssignmentNode
|
||||
assignments: [AssignmentNode]
|
||||
node(id: ID!): Node
|
||||
topic(slug: String): TopicNode
|
||||
topic(slug: String): TopicOr404Node
|
||||
module(slug: String, id: ID): ModuleNode
|
||||
chapter(id: ID!): ChapterNode
|
||||
contentBlock(id: ID!): ContentBlockNode
|
||||
|
|
@ -1127,6 +1131,8 @@ type TopicNode implements Node {
|
|||
modules(offset: Int, before: String, after: String, first: Int, last: Int, slug: String, slug_Icontains: String, slug_In: [String], title: String, title_Icontains: String, title_In: [String]): ModuleNodeConnection
|
||||
}
|
||||
|
||||
union TopicOr404Node = TopicNode | NotFound
|
||||
|
||||
scalar UUID
|
||||
|
||||
input UpdateAnswerArgument {
|
||||
|
|
|
|||
Loading…
Reference in New Issue