Is there any way to pass an argument the fetcher but omit it from the query keys?
I have a fairly complex object that I am passing
down that my fetcher needs but I dont really
want as a query key and react query cant
serialize it anyways
6 Replies
broad-brown•4y ago
Hey there is a meta option that may be useful to you?

deep-jadeOP•4y ago
That might be exactly what I need
absent-sapphire•4y ago
just be aware of stale closure problems. if the query refetches, it will use whatever you passed as meta when the query was created
you can use a ref though 🙂
absent-sapphire•4y ago
Dominik 🇺🇦 (@TkDodo)
🤨I'm not entirely sure why I tried to do this today, but it does work. Note that it doesn't if you pass
ref.current directly because meta is stored on the query so it needs the whole ref to lazily access .current
Don't try this at home / work - use the queryKey🤪
Twitter
deep-jadeOP•4y ago
Thanks for this! The ref method worked. I couldnt pass this arg as a queryKey because it was causing some serialization issues with React Query (It was a client object). Ideally this client object would be in the fetcher, but couldnt in this case
absent-sapphire•4y ago
you can also pass your custom
queryKeyHashFn