urql-graphql / urql

The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.
https://urql.dev/goto/docs
MIT License
8.6k stars 448 forks source link

fix(react): Fix execute functions' state change being discarded after pause change #3323

Closed kitten closed 1 year ago

kitten commented 1 year ago

Resolves #3289 Supersedes #3289

Summary

This updates the outdated dependencies array in react-urql’s useQuery (which still contained getSnapshot) and adds args.pause. It does the same in useSubscription.

When executeQuery/executeSubscription are not re-created when all dependencies change, the first render when they're outdated would refresh the dependencies to an older version, causing the source to be immediately overridden again.

This specifically caused an edge case because the dependencies didn't include args.pause. This means that the execute functions are outdated the render after args.pause changes, and means that their state change is immediately overwritten.

Set of changes