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

Invalidate with a key does not produce expected result #3543

Closed BickelLukas closed 3 months ago

BickelLukas commented 3 months ago

Describe the bug

The documentation says that for the "entity" parameter it can be a GraphQL object or an entity key:

image

but calling cache.invalidate("123") does not work as expected.

The problem is the shouldInvalidateType check when trying to invalidate just a single entity without fields or args https://github.com/urql-graphql/urql/blob/431b64b4086d3d1dafb2af4881a95fa642134daf/exchanges/graphcache/src/store/store.ts#L167-L171

because of this it is now trying to invalidate the type "123" instead of the entity with id "123"

Reproduction

In Description

Urql version

urql: 4.0.6 @urql/exchange-graphcache: 6.5.0

Validations

JoviDeCroock commented 3 months ago

This is fixed and released with #3544

BickelLukas commented 3 months ago

Works perfectly now. Thanks for the amazingly quick fix and release! 🎉