react-apollo-hooks icon indicating copy to clipboard operation
react-apollo-hooks copied to clipboard

skip option prevents updating the query

Open jide opened this issue 6 years ago • 0 comments

When using the skip option, if we update the cache while the query is skipped, and then change the variable that enables skip, the next query result does not reflect the cache :

const [skip, setSkip] = useState(false);

const { data } = useQuery(QUERY, {
  suspend: true,
  skip
});

// data = { something: true }

setSkip(true);

// Somewhere we update the cache, setting something: false

setSkip(false);

// data = { something: true }

I believe this is because of the early return when skip is true here : https://github.com/trojanowski/react-apollo-hooks/blob/master/src/useQuery.ts#L158

Maybe because the invalidation happens here ? https://github.com/trojanowski/react-apollo-hooks/blob/master/src/useQuery.ts#L176

jide avatar Mar 20 '19 12:03 jide