Replies: 1 comment
-
Primarily: not one more thing that we need to maintain that already exists.
There is nothing particularly complex around it, especially if you have full control over the server. If you were to write a fully generic solution, you'd have to be aware of specifics like that different HTTP codes are interpreted differenly in GraphQL over HTTP based on accept/content-type headers, but if you only talk with one server, you probably don't need to implement negotiation mechanisms for that. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Looking through the history of my repo, I see that I added a custom graphqlBaseQuery function, based on
graphql-request, several months after you addedrtk-query-graphql-request-base-queryto the RTK monorepo. I am sure I wasn't even aware thatrtk-query-graphql-request-base-queryexisted; I must have based mine on @phryneas's earlier example, which usedgraphql-request'srequestfunction, and looked nice and simple.Years went by;
graphql-requestgot updated to version 7, which I was unable to upgrade to for a long while because it was ESM-only, and I was runningjest. Only recently, after finally migrating fromjesttovitest, I updated all the dependencies that were previously blocked on jest, and realised that since version 7,graphql-requestalways requires that the url is absolute, where previously it was happy with relative urls. They are also deprecating thegqlfunction, probably for a good reason. And although they still export the plainrequestfunction, they don't include it anywhere in their documentation.All of this made me wonder — what is the benefit of using
graphql-requestin the context of RTK-Q? Why not build a graphql base query on top of plain fetch? What are the pitfalls I should be looking out for if I decide to migrate my graphqlBaseQuery function to plain fetch?Beta Was this translation helpful? Give feedback.
All reactions