Skip to content

How can I subscribe to a specific cache entry without triggering a request? #4213

Answered by EskiMojo14
ensconced asked this question in Q&A
Discussion options

You must be logged in to vote

useLazyQuerySubscription doesn't subscribe until it's triggered.

Generally we don't provide anything specific for this use case because by creating a subscription you're saying you want that data, so it only makes sense to fetch the data if it's not already there.

I guess you could hack something together with useQueryState and useQuerySubscription, skipping your subscription if the state is uninitialized:

const { data, isUninitialized } = useQueryState(arg)
const { refetch } = useQuerySubscription(arg, { skip: isUninitialized })

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by ensconced
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants