Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add way to provider updater types to queryclient.setQueryData with createConnectQueryKey #391

Closed
nickzelei opened this issue Jul 12, 2024 · 2 comments

Comments

@nickzelei
Copy link

nickzelei commented Jul 12, 2024

Hey all, I'm playing with the createConnectQueryKey and I'm wondering if there is a way to allow TS to better infer the return type when using it in conjunction with the tanstack queryclient.setQueryData.

It's able to infer the some of the types, but not all of them. Arguably the most important being the actual value that the cache is going to be updated to.

Screenshot below shows an example. TS is definitely inferring some of the types, but the updater is still set to unknown.
It would be awesome if by passing in the query key if the updater could be set to the response type, in this case, GetAccountOnboardingConfigResponse

image
@timostamm
Copy link
Member

I don't think TanStack's QueryClient.setQueryData - which we are using here - can infer data type from the key type. To enforce matching key and value, we'd have to provide our own API to set query data.

@timostamm
Copy link
Member

Closing in favor of #390.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants