Skip to content

Commit

Permalink
Reinstate MutationUpdaterFn for back-compat, with deprecation note.
Browse files Browse the repository at this point in the history
Following a suggestion from @bennypowers in this comment:
#7895 (comment)
  • Loading branch information
benjamn committed Jul 28, 2021
1 parent 7856c18 commit b677262
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
- 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/>
[@ArnaudBarre](https://github.com/ArnaudBarre) in [#7476](https://github.com/apollographql/apollo-client/pull/7476)

- Pass `variables` and `context` to a mutation's `update` function <br/>
- 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/>
[@jcreighton](https://github.com/jcreighton) in [#7902](https://github.com/apollographql/apollo-client/pull/7902)

- 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/>
Expand Down
9 changes: 9 additions & 0 deletions src/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ export type MutationQueryReducersMap<T = { [key: string]: any }> = {
[queryName: string]: MutationQueryReducer<T>;
};

// @deprecated Use MutationUpdaterFunction instead.
export type MutationUpdaterFn<T = { [key: string]: any }> = (
// The MutationUpdaterFn type is broken because it mistakenly uses the same
// type parameter T for both the cache and the mutationResult. Do not use this
// type unless you absolutely need it for backwards compatibility.
cache: ApolloCache<T>,
mutationResult: FetchResult<T>,
) => void;

export type MutationUpdaterFunction<
TData,
TVariables,
Expand Down

0 comments on commit b677262

Please sign in to comment.