Mirror: The highly customizable and versatile GraphQL client with which you add on features like normalized caching as you grow.

fix updateQuery updater function type (#538)

* fix updateQuery updater function type

* add changeset

* remove fallback

* Update .changeset/famous-ducks-smash.md

Co-Authored-By: Phil Plückthun <phil@kitten.sh>

Co-authored-by: Phil Plückthun <phil@kitten.sh>

Changed files
+8 -2
.changeset
exchanges
graphcache
src
store
+5
.changeset/famous-ducks-smash.md
···
···
+
---
+
'@urql/exchange-graphcache': patch
+
---
+
+
Update the `updater` function type of `cache.updateQuery` to have a return type of `DataFields` so that `__typename` does not need to be defined.
+3 -2
exchanges/graphcache/src/store/store.ts
···
UpdatesConfig,
OptimisticMutationConfig,
KeyingConfig,
} from '../types';
import { read, readFragment } from '../operations/query';
···
updateQuery(
input: QueryInput,
-
updater: (data: Data | null) => Data | null
): void {
const request = createRequest(input.query, input.variables);
const output = updater(this.readQuery(request as QueryInput));
if (output !== null) {
-
startWrite(this, request, output);
}
}
···
UpdatesConfig,
OptimisticMutationConfig,
KeyingConfig,
+
DataFields,
} from '../types';
import { read, readFragment } from '../operations/query';
···
updateQuery(
input: QueryInput,
+
updater: (data: Data | null) => DataFields | null
): void {
const request = createRequest(input.query, input.variables);
const output = updater(this.readQuery(request as QueryInput));
if (output !== null) {
+
startWrite(this, request, output as Data);
}
}