Replies: 3 comments 3 replies
-
The functions to generate query keys are not private https://github.com/wevm/wagmi/blob/main/packages/core/src/query/getBalance.ts |
Beta Was this translation helpful? Give feedback.
-
Check out the TanStack Query Guide in the Wagmi docs. |
Beta Was this translation helpful? Give feedback.
-
After mulling about this for a bit — it doesn't solve the fundamental issue, right? You get Whereas when using tanstack-query directly, you can define your own key, meaning you can have a file that defines all your query keys and import it easily in different components. Not the end of the world, you can put your query keys in a store when they get defined. |
Beta Was this translation helpful? Give feedback.
-
Simple example: I read an ERC20 balance from one component. I have a token transfer form in another component. Whenever I send token I want the ERC20 balance to refetch.
Right now, the canonical solution seems to be to pass the
refetch
function from the balance read to the form. Easy pez if the transfer form is a child of the component doing the read. If they're siblings, it means moving the read to the common ancestor, which in some cases is pretty bad for code organization.The ideal solution would be to have something like tanstack-query query keys to invalidate via a string identifier or symbol. But wagmi reserves the query key for internal use and doesn't seem to expose a similar functionality.
Is there a better way to do this than passing refetch? Probably reimplementing a query-key like mechanism on top of wagmi is the way (it's not that difficult), but I wanted to make sure there wasn't a better way. This seems like a super super super common use case.
Beta Was this translation helpful? Give feedback.
All reactions