Server-side caching for your GraphQL resolvers
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.babelrc
.gitignore
.npmignore
.prettierignore
.prettierrc
LICENSE
README.md
package-lock.json
package.json

README.md

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

🐘