Skip to content

Instantly share code, notes, and snippets.

@AugustoCalaca
Last active April 5, 2020 02:16
Show Gist options
  • Save AugustoCalaca/11b550276e61d22919ae97ef2e9cf63f to your computer and use it in GitHub Desktop.
Save AugustoCalaca/11b550276e61d22919ae97ef2e9cf63f to your computer and use it in GitHub Desktop.
register types loaders
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