Skip to content

Instantly share code, notes, and snippets.

@erebus1
Last active November 12, 2019 13:58
Show Gist options
  • Save erebus1/207b9aa2e12173532d1cbc8241964246 to your computer and use it in GitHub Desktop.
Save erebus1/207b9aa2e12173532d1cbc8241964246 to your computer and use it in GitHub Desktop.
from graphene import Schema, ObjectType, Int, String, List, NonNull
from utils import file_loader # custom data loader
class FileNode(ObjectType):
id = Int(required=True)
url = String(required=True)
class MessageNode(ObjectType):
id = Int(required=True)
thread_id = Int(required=True)
author_id = Int()
files = List(NonNull(FileNode))
body = String(required=True)
def resolve_files(self, info):
return file_loader.load(message_id=self.id)
class Query(ObjectType):
messages = List(NonNull(MessageNode))
schema = Schema(query=Query)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment