Open
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Fastify version
4.5.3
Plugin version
^9.0.0
Node.js version
18
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
macosx
Description
First thanks for this library,
I am trying to create a graphql proxy with caching capabilities. Therefor I am trying to use fastify.addHook('preHandler', ...)
to parse the query and possibly retrieve result from cache and fastify.addHook('onSend', ...)
to store the cache however I am kind of stuck on storing the cache value from onSend hook. In general, how can cache be implemented inside proxy using fastify-http-proxy
?
Steps to Reproduce
fastify.register(async (fastify) => {
fastify.addHook("preHandler", async (req) => {
console.log({ body: req.body });
// retrieve from cache
});
fastify.addHook("onSend", async (req, reply, payload) => {
// payload is BodyReadable
console.log({ payload: payload });
// set the cache
});
fastify.register(fastifyProxy, {
upstream: "http://localhost:8082/v1/graphql",
proxyPayloads: false,
prefix: "/v1/graphql",
// undici: {},
websocket: true,
});
});
})
Expected Behavior
Metadata
Metadata
Assignees
Labels
No labels