gQuery icon indicating copy to clipboard operation
gQuery copied to clipboard

Allow custom fetch on mutations (small PR)

Open scottBowles opened this issue 3 years ago • 2 comments

Currently, queries accept a custom fetch (mainly for SvelteKit's SSR fetch) but mutations use the browser's fetch, since they will always have access to it. This PR will allow the developer to pass a custom fetch to both.

Why?

For those of us using external apis and needing to add an Authorization header to the request. Like the SvelteKit RealWorld example app, I store a jwt in a cookie, receive the cookie in the handle hook, and put the jwt in the session. In order to hit the external api directly with gQuery rather than routing everything through a SvelteKit endpoint, it makes sense to retrieve the token from the session store whenever I need to hit the api. Given access to the fetch function, I can easily wrap fetch and add the token to the Authorization header. But gQuery's current implementation doesn't allow for this on mutations since I have no access to the fetch function being used.

scottBowles avatar Apr 13 '22 00:04 scottBowles

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

height[bot] avatar Apr 13 '22 00:04 height[bot]

Good call but I think I have something different in mind to solve this. Will update soon.

stolinski avatar Jun 21 '22 18:06 stolinski