Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

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

2

Version

1.0.0

License

MIT

Unpacked Size

12.2 kB

Total Files

6

Last publish

Collaborators

  • avatar