Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Calling suspense on a query ignores the `enabled` config option

See original GitHub issue

Version: 2.0.0-beta.5

Possibly related to #200.

When calling useQuery({ enabled: false })).suspense() the query will run regardless of the enabled value being false.


I’m chaining query calls like this:

const enabled: Ref<boolean> = ... // Some reactive value from somewhere, ie Provide/Inject
const data = await useQuery({ enabled }).suspense()

My intent is to suspend the component from loading until enabled is set to true. In my case, I’m waiting on a global auth state to become true.

I’ll be happy to help contribute in a PR.

Side issue: Does the dev tools update the state of the options if the options are reactive and change? It doesn’t seem to update in my case.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

kevin-courbetcommented, Sep 12, 2022

@DamianOsipiuk I can confirm it is fixed! Cheers

DamianOsipiukcommented, Sep 9, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

new useQueries API · Issue #2923 · TanStack/query
just taking an Array of useQuery objects doesn't cover all the cases, because some options have to be the same for all queries,...
Read more >
Disabling/Pausing Queries
The query will ignore query client invalidateQueries and refetchQueries calls that would normally result in the query refetching. refetch returned from useQuery ...
Read more >
Hooks - Apollo GraphQL Docs
A callback function that's called when the query encounters one or more errors (unless errorPolicy is ignore ). This function is passed an...
Read more >
Suspense for Data Fetching (Experimental)
We call this approach “fetch-on-render” because it doesn't start fetching until after the component has rendered on the screen. This leads to a...
Read more >
To enable this mode, you can set either the global or query level config's `suspense` option to `true`. 999. 1000, Global configuration:.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found