You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
exportconstgetUserQueryQueryKey=(options?: OptionsLegacyParser<GetUserQueryData>)=>[createQueryKey('getUserQuery',options),]exportconstgetUserQueryOptions=(options?: OptionsLegacyParser<GetUserQueryData>)=>{returnqueryOptions({queryFn: async({ queryKey, signal })=>{// watch out: response header is discarded here!const{ data }=awaitgetUserQuery({
...options,
...queryKey[0],
signal,throwOnError: true,})returndata},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!
The text was updated successfully, but these errors were encountered:
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:
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!
The text was updated successfully, but these errors were encountered: