Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript. Learn more »

graphql-memo

1.0.0 • Public • Published

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);
+     }),
    },
  }),
});

🐘

install

npm i graphql-memo

Downloadsweekly downloads

22

version

1.0.0

license

MIT

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability