Intercept every request
Hi there,
Is there a way how to intercept every request call? For example in case response contains errors I want to deal with them in generic way.
thanks
Do we have any update on intercepting the request?
Any update ?
Tagging @jasonkuhrt who has merged recent commits in this project.
A more robust middleware would be extremely valuable. In addition to global error handling, this would enable generating proper telemetry data (i.e. spans qualified by GraphQL operation names).
Are there any plans to support this? If not, is there a more robust Node.js library alternative?
This issue is duplicated by:
- https://github.com/prisma-labs/graphql-request/issues/255
- https://github.com/prisma-labs/graphql-request/issues/297
I'm trying this technique of "monkey patching" fetch as shown here: https://blog.logrocket.com/intercepting-javascript-fetch-api-requests-responses/
This works for all my fetch requests except those made via this graphql-request library. Is this lib not using fetch under the hood? It seems like it does (cross-fetch), but I can't figure out what's not working here. Anyone have any ideas why not?
If you update to latest version the middlewares might solve your problem. Request and response.
It did for me.
There is middleware now: https://github.com/jasonkuhrt/graphql-request/blob/main/examples/other-middleware.ts.