react-apollo-hooks
react-apollo-hooks copied to clipboard
skip option prevents updating the query
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