Last active
April 5, 2020 02:16
-
-
Save AugustoCalaca/11b550276e61d22919ae97ef2e9cf63f to your computer and use it in GitHub Desktop.
register types loaders
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
export type DataLoaderKey = string | Types.ObjectId | Object; | |
export type Load = (context: GraphQLContext, id: DataLoaderKey) => any; | |
type TypeLoaders = { | |
[key: string]: { | |
type: GraphQLObjectType, | |
load: Load, | |
}; | |
}; | |
const typesLoaders: TypeLoaders = {}; | |
export const registerTypeLoader = (type: GraphQLObjectType, load: Load) => { | |
typesLoaders[type.name] = { | |
type, | |
load, | |
}; | |
return type; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment