I am using @apollo/react-hooks and I wanted to know if there is a way to conditionally trigger or prevent a query?
There are many use cases I have, one of it is server sider rendering, where I can set my props on the server with, but even if I redirect before, the component is rendered and the query hook is called.
It would be nice to have a flag that tells the hook to not fetch data.
https://www.apollographql.com/docs/react/data/queries/#executing-queries-manually
Also skip option
Agree with @dmt0 - I make extensive use of the skip option to conditionally fire queries using apollo hooks. Great for waiting until other things are loaded etc to prevent wasteful queries.
@michael-watson @dmt0 there is a problems with using skip though that queries actually takes place but are later nullified at the client, so one only "pretends " not to query Here are the details
@JayMGurav works perfectly well in V2. I gave up trying to update to V3 - too many really basic things not working.
Most helpful comment
@JayMGurav works perfectly well in V2. I gave up trying to update to V3 - too many really basic things not working.