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(graphcache): Mutable links on InMemoryData store #3516

Closed kitten closed 4 months ago

kitten commented 4 months ago

See related PR: https://github.com/urql-graphql/urql/pull/3503

Summary

When cache.resolve returns a list of entity links, i.e. an array link, a user may be tempted to mutate this list before writing it back to the store.

This can have unforeseen consequences if:

This is because, unlike cache.link, cache.resolve doesn't make a copy of links before returning them. This means that mutating a link array leads to direct modifications to the internal caching layer.

Set of changes

changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: 38d31944630bc86308331887bf290de86fbfd389

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-graphcache | Patch |

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