-
Hi Team, const server = new ApolloServer({ Query: { Mutation: { type Mutation { Any help is really appreciate on this. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Passing This cache isn't made directly available to your resolvers. The "context" object on which you are looking for a However I wouldn't recommend you actually do that. The whole point of the abstract cache interface is to let Apollo Server's features work with any backend. But if you know you are using Redis, you don't need an abstraction. I suggest that you just use your favorite Redis client (eg https://www.npmjs.com/package/ioredis), create an ioredis client at startup, and put it on your Something like:
See https://www.apollographql.com/docs/apollo-server/data/resolvers/#the-context-argument for more details on the context function. |
Beta Was this translation helpful? Give feedback.
Passing
cache
tonew ApolloServer
makes the cache available for Apollo Server's own features (implemented in core or in plugins) that want to use a cache, such as the full operation response cache, the HTTP cache for the REST Data Source, the Automatic Persisted Query cache, etc. We have an interfaceKeyValueCache
that we use to allow multiple implementations to work for these features (though we are planning to replace this with another project's abstraction, see #6045).This cache isn't made directly available to your resolvers. The "context" object on which you are looking for a
client
is actually completely controlled by thecontext
function you pass to your ApolloServer constructor. …