This repository was archived by the owner on Jul 3, 2024. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thesession
. 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 wrapfetch
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 thefetch
function being used.