defaultOptions for ApolloClient is being ignored (awaitRefetchQueries)
Intended outcome:
According to the docs section - https://www.apollographql.com/docs/react/api/apollo-client/#optional-fields defaultOptions provides application-wide default values for options.
So by providing the following code:
const client = new ApolloClient({
...,
defaultOptions: {
mutate: {
awaitRefetchQueries: true
}
}
});I'd expect awaitRefetchQueries flag to be passed to all my mutations. The reproduce section describes how to get the issue.
Actual outcome:
This is caused by a ApolloClient.mutate function with a predefined value for awaitRefetchQueries = false here (lines 87 and 104):
but when ApolloClient merges the provided options param with the defaultOptions here - it's too late, it'll always remain awaitRefetchQueries = false.
How to reproduce the issue:
https://codesandbox.io/s/apollo-client-error-template-c0zj8
- 2 buttons represent mutation calls with and without the overridden
awaitRefetchQueriesflag - the console tab shows the order of the events
Previously confirmed on https://github.com/apollographql/react-apollo/issues/2643#issuecomment-564921568
Version
System:
OS: macOS Mojave 10.14.6
Binaries:
Node: 12.13.1 - /usr/local/bin/node
Yarn: 1.21.1 - /usr/local/bin/yarn
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.79
Firefox: 71.0
Safari: 13.0.4
npmPackages:
@apollo/react-hoc: ^3.1.3 => 3.1.3
@apollo/react-hooks: ^3.1.3 => 3.1.3
apollo-client: 2.6.4 => 2.6.4Source: apollographql/react-apollo