Skip to content

Commit b677262

Browse files
committed
Reinstate MutationUpdaterFn for back-compat, with deprecation note.
Following a suggestion from @bennypowers in this comment: #7895 (comment)
1 parent 7856c18 commit b677262

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
- The `FetchMoreQueryOptions` type now takes two instead of three type parameters (`<TVariables, TData>`), thanks to using `Partial<TVariables>` instead of `K extends typeof TVariables` and `Pick<TVariables, K>`. <br/>
3838
[@ArnaudBarre](https://github.com/ArnaudBarre) in [#7476](https://github.com/apollographql/apollo-client/pull/7476)
3939

40-
- Pass `variables` and `context` to a mutation's `update` function <br/>
40+
- Pass `variables` and `context` to a mutation's `update` function. **Note:** The type of the `update` function is now named `MutationUpdaterFunction` rather than `MutationUpdaterFn`, since the older type was [broken beyond repair](https://github.com/apollographql/apollo-client/issues/8506#issuecomment-881706613). If you are using `MutationUpdaterFn` in your own code, please use `MutationUpdaterFunction` instead. <br/>
4141
[@jcreighton](https://github.com/jcreighton) in [#7902](https://github.com/apollographql/apollo-client/pull/7902)
4242

4343
- A `resultCacheMaxSize` option may be passed to the `InMemoryCache` constructor to limit the number of result objects that will be retained in memory (to speed up repeated reads), and calling `cache.reset()` now releases all such memory. <br/>

src/core/types.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ export type MutationQueryReducersMap<T = { [key: string]: any }> = {
158158
[queryName: string]: MutationQueryReducer<T>;
159159
};
160160

161+
// @deprecated Use MutationUpdaterFunction instead.
162+
export type MutationUpdaterFn<T = { [key: string]: any }> = (
163+
// The MutationUpdaterFn type is broken because it mistakenly uses the same
164+
// type parameter T for both the cache and the mutationResult. Do not use this
165+
// type unless you absolutely need it for backwards compatibility.
166+
cache: ApolloCache<T>,
167+
mutationResult: FetchResult<T>,
168+
) => void;
169+
161170
export type MutationUpdaterFunction<
162171
TData,
163172
TVariables,

0 commit comments

Comments
 (0)