Last active
November 12, 2019 13:58
-
-
Save erebus1/207b9aa2e12173532d1cbc8241964246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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