You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However the underlying DataProxy defines ReadQueryOptions like so:
exportinterfaceReadQueryOptions<TData,TVariables>extendsQuery<TVariables,TData>{/** * Whether to return incomplete data rather than null. * Defaults to false. */returnPartialData?: boolean;/** * Whether to read from optimistic or non-optimistic cache data. If * this named option is provided, the optimistic parameter of the * readQuery method can be omitted. Defaults to false. */optimistic?: boolean;/** * Whether to canonize cache results before returning them. Canonization * takes some extra time, but it speeds up future deep equality comparisons. * Defaults to false. */canonizeResults?: boolean;}
Is this done intentionally to prevent ApolloClient.readQuery from receiving the full cache options? Currently (although not type-safe), it's possible to pass returnPartialData: true to client.readQuery. This would be super useful for our use case, but we don't want to use it if it's an unintentional escape hatch.
The text was updated successfully, but these errors were encountered:
This appears to be more of an oversight rather than intentional restriction. Since client.readQuery just forwards the call to client.cache.readQuery, there is no reason those types shouldn't line up. Updating to DataProxy.ReadQueryOptions is a backwards compatible change, so this should be safe to change.
Would you be willing to open a PR to update the type here? We'd be happy to accept it.
One note on a small tweak I'd make when doing so. Notice how DataProxy.ReadQueryOptions accepts an optimistic option, yet our client.readQuery function has an optimistic argument as the 2nd argument. For backwards compatibility, we'll want to leave this alone, but to avoid confusion I think we should omit optimistic from options in the type since the optimistic argument is going to override anything in options.
The implementation of
ApolloClient.readQuery
defines itsoptions
asDataProxy.Query
like so:https://github.com/apollographql/apollo-client/blob/main/src/core/ApolloClient.ts#L415-L420
However the underlying
DataProxy
definesReadQueryOptions
like so:https://github.com/apollographql/apollo-client/blob/main/src/cache/core/types/DataProxy.ts#L58-L77
Is this done intentionally to prevent
ApolloClient.readQuery
from receiving the full cache options? Currently (although not type-safe), it's possible to passreturnPartialData: true
toclient.readQuery
. This would be super useful for our use case, but we don't want to use it if it's an unintentional escape hatch.The text was updated successfully, but these errors were encountered: