remorses / genql

Type safe TypeScript client for any GraphQL API
https://genql.dev
MIT License
881 stars 37 forks source link

Missing support for custom request options per request #166

Closed lucasprins closed 8 months ago

lucasprins commented 8 months ago

When using Next.js App Router it is needed to be able to specify additional fetch paramaters per request such as revalidation tags and cache control headers. Is this not possible currently?

https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating

remorses commented 8 months ago

you can create different clients for each option, to pass the options you can override the fetch function

https://genql.dev/docs/usage/create-the-client#60b057b56b1340b099732ced94b26571

lucasprins commented 8 months ago

Sorry but that doesn't seem very efficient, that means creating a seperate client for each mutation and query. I forked the repo locally and added a second argument to queries and mutations which is a RequestInit object, would that be a good solution maybe?

remorses commented 8 months ago

creating a client isn't an inefficient task, usually you won't have many cache tags or different revalidation parameters, typically 2 or 3