-
-
Notifications
You must be signed in to change notification settings - Fork 265
Open
Labels
feature 🚀New feature or requestNew feature or request
Description
Description
Hi,
I use the TanStack Query code generator and need access to response header.
In my scenario, REST-API requires 'If-Unmodified-Since' header to be passed to properly handle concurrent updates.
For this, I need to extract 'last-modified' from response headers. Actually, this looks like being almost impossible with code generated by HeyAPI.
E.g. I have an endpoint to retrieve information about a user. HeyAPI generates the following code for this:
export const getUserQueryQueryKey = (options?: OptionsLegacyParser<GetUserQueryData>) => [
createQueryKey('getUserQuery', options),
]
export const getUserQueryOptions = (options?: OptionsLegacyParser<GetUserQueryData>) => {
return queryOptions({
queryFn: async ({ queryKey, signal }) => {
// watch out: response header is discarded here!
const { data } = await getUserQuery({
...options,
...queryKey[0],
signal,
throwOnError: true,
})
return data
},
queryKey: getUserQueryQueryKey(options),
})
}You see that the response header is discarded deeply inside.
Effectively, I have to rewrite getUserQueryQueryKey() and getUserQueryOptions(). That's kind of OK for a single API-endpoint, but not suitable for my application.
So: is there any idea to handle this more generic?
Thank you!
Metadata
Metadata
Assignees
Labels
feature 🚀New feature or requestNew feature or request