As detailed in @apollo/client
GitHub issue #9923, the behavior of ApolloQueryResult
and nextFetchPolicy: 'cache-only'
changed in @apollo/client@3.6.9
such that some queries in our project are returning results with partial: true
with nextFetchPolicy: 'cache-only'
(which we have set in our project to prevent refetching queries on cache.evict()
while still getting cache updates from other requests/explicit refetches). Partial data is incorrectly returned in both ObservableQuery
(Apollo Angular QueryRef.valueChanges
Observable ApolloQueryResult
) emissions and in ObservableQuery.result()
subscriptions.
The problem seems to be restricted to queries on custom types which have field parameters on multiple array fields similar to the simplified example below. Our application has multiple queries on the same parent document, some of which return only the non-Array properties, some only the _id
and one array property (“ParentReadList1’”), some only the _id
and another array property (“ParentListRead2”). We observer these queries being sent over the network and the data returned includes all the correct fields but the local ObservableQueries are sometimes emitting partial results to their respective consumers, specifically just objects with _id
and __typename
fields, not the requested childListN
arrays. Perhaps we have multiple queries in flight simultaneously with requests for the same Parent but different fields and the local ObservableQueries are being fulfilled from the result of a differently shaped query on the same Parent _id
? I’m not sure why that would happen with the default partial: false
setting but that’s as close as I’ve been able to narrow the problematic new behavior in 3.6.9 (persisting through the latest 3.7.3 release) down to so far.
type Parent {
_id: ID!
name: String!
childList1 (someParameter: String!: [Child!]
childList2 (someParameter: String!): [Child!]
}
query ParentRead($id: ID!, $list1Filter: String) {
Parent(id: $id) {
id
name
}
}
query ParentReadList1($id: ID!, $list1Filter: String) {
Parent(id: $id) {
id
name
childList1(filter: $list1Filter) {
id
name
}
}
}
query ParentReadList2($id: ID!, $list1Filter: String) {
Parent(id: $id) {
id
name
childList2(filter: $list1Filter) {
id
name
}
}
}
Unfortunately, I have not yet been able to reproduce this behavior in a simplified reproduction of this type of query using local resolvers. Any pointers on further troubleshooting and diagnosis are greatly appreciated!