Last active
November 12, 2019 13:56
-
-
Save erebus1/191afbe847d13cdc0c73c7b35dc38f1f 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
import graphene | |
from graphene import ObjectType, Int, String | |
from graphene_federation import build_schema, key | |
from utils import file_loader # custom data loader | |
@key(fields='id') | |
class FileNode(ObjectType): | |
id = Int(required=True) | |
url = String(required=True) | |
def __resolve_reference(self, info, **kwargs): | |
if not info.context.user.is_authenticated: | |
return None | |
return file_loader.load(self.id) | |
class Query(ObjectType): | |
pass | |
schema = build_schema(Query, types=[FileNode]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment