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.54k stars 444 forks source link

fix(request-policy): avoid relying on cache internals to assert misses #3521

Closed JoviDeCroock closed 4 months ago

JoviDeCroock commented 4 months ago

Resolves #3508

Summary

This PR removes the logic of asserting the cacheState of a given operation and moves us to asserting whether the operation was resolved synchronously. When we are dealing with a synchronously resolved operation we can see this as a cache-hit, when it's higher than the last dispatched we can see this as a cache miss.

## Operation with cache-first
cache-first --> request-policy (time 1) --> cache-miss --> fetch --> request-policy (time x > 1)
## Operation with cache-and-network
cache-and-network--> request-policy (time 1) --> cache-hit --> request-policy (time = 1) --> fetch --> request-policy (time x > 1)
changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: 48b029a8b26c5a5d6d6e9f15048db5495c90df68

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ----------------------------- | ----- | | @urql/exchange-request-policy | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR