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

When using skipToken all the data results are unknown #100

Open
lukasbash opened this issue Oct 6, 2024 · 3 comments
Open

When using skipToken all the data results are unknown #100

lukasbash opened this issue Oct 6, 2024 · 3 comments

Comments

@lukasbash
Copy link

When working with dependent queries I am often times using the skipToken export, provided by react query. When using a query configuration in the semantics of e.g.:

foo: (baz: number | undefined ) => {
 queryKey: ["bar", baz],
 queryFn: baz ? new Promise<number>() : skipToken
}

The resulting data is not number | undefined but rather always unknown.

Copy link

linear bot commented Oct 6, 2024

@senaria
Copy link

senaria commented Oct 9, 2024

Looks like the same issue happens when using the skipToken in vue query. E.g. when using the recommended way of using a computed as the queryFn argument that either returns the function or the skip token. See this

      queryFn: computed(() => {
        const value = toValue(id)
        return value ? () => userApi.fetchById(value).then((response) => response.data) : skipToken
      })

@Pirulax
Copy link

Pirulax commented Nov 2, 2024

Any solutions for this?
Other than manually typing out UseQueryResult for each hook?
Edit: Seems like doing () => value ? fetch() : skipToken works fine (Instead of value ? () => fetch() : skipToken). Never mind, the resulting UseQueryResult contains unique symbol, so not good either.

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

3 participants