Issue Description
client.readFragment is implemented as such:
public readFragment<
TData = unknown,
TVariables extends OperationVariables = OperationVariables,
>(
options: ApolloClient.ReadFragmentOptions<TData, TVariables>,
optimistic: boolean = false
): Unmasked<TData> | null {
return this.cache.readFragment<TData, TVariables>(
{ ...options, fragment: this.transform(options.fragment) },
optimistic
);
}
We have 2 function overrides for this API to allow optimistic to be passed in either options or as the 2nd argument (this form is currently deprecated). However, due to the implementation, client.readFragment({ optimistic: true }) does not correctly return the optimistic fragment since the default false value overrides options.optimistic.
The current workaround is to call client.cache.readFragment(...) or client.readFragment(options, true) to get the optimistic response, but we should fix this so that options.optimistic is properly passed to cache.readFragment.
Link to Reproduction
n/a
Reproduction Steps
See description.
@apollo/client version
4.2.3
Issue Description
client.readFragmentis implemented as such:We have 2 function overrides for this API to allow
optimisticto be passed in either options or as the 2nd argument (this form is currently deprecated). However, due to the implementation,client.readFragment({ optimistic: true })does not correctly return the optimistic fragment since the defaultfalsevalue overridesoptions.optimistic.The current workaround is to call
client.cache.readFragment(...)orclient.readFragment(options, true)to get the optimistic response, but we should fix this so thatoptions.optimisticis properly passed tocache.readFragment.Link to Reproduction
n/a
Reproduction Steps
See description.
@apollo/clientversion4.2.3