graphql-memo
v1.0.0
Published
Server-side caching for your GraphQL resolvers
Downloads
4
Maintainers
Readme
graphql-memo
$ npm install --save graphql-memo
import memo from 'graphql-memo';
const { cache } = memo({ store: new Map() });
const Query = new GraphQLObjectType({
name: 'Query',
fields: () => ({
hello: {
type: GraphQLString,
args: {
name: { type: GraphQLString, defaultValue: 'world' },
},
- resolve: async (root, { name }, context, info) => {
- return Promise.resolve(name);
- },
+ resolve: cache(async (root, { name }, context, info) => {
+ return Promise.resolve(name);
+ }),
},
}),
});