T
TanStack3y ago
ratty-blush

how to lazy query? is ok use mutation for it?

since we dont have lazy query what is the recommended way to do it? use mutation is fine to it? doesnt seems right but why tf we dont have lazyquery
4 Replies
equal-jade
equal-jade3y ago
what do you mean by lazy query? you have the enabled flag, you can start the query whenever you want
legitimate-teal
legitimate-teal3y ago
If you literally type "lazy queries" into the search of the docs, you'll find the right answer...
old-apricot
old-apricot3y ago
What if you want to only trigger a request on the click of a button for example. Setting a state to then set enabled to true to then trigger the request feels a bit odd. Let's say you want an Get Server Timestamp button for example. If we use disabled together with refetch then the query cache won't work right and then we have to add a state to enable the query I guess?
legitimate-teal
legitimate-teal3y ago
what would you do with the result then? Can you show a complete example?

Did you find this page helpful?