nested fragment data returning null from cache
See original GitHub issueHello,
I am experiencing this issue in React Native using Apollo Client: I have a query containing a fragment and in it a nested fragment; when the query runs the first time (empty cache) the result is returned correctly and I can see data inside the fragment and the nested fragment; on the following rendering, when the result returns from the cache (default fetchPolicy), data is correctly returned except the nested fragment which contains “null”. I don’t manually manipulate the cache in any way on this query and we have no inMemoryCache configuration for it or its fields.
The nested fragment does NOT have an id but I tried setting a keyField on another field and nothing changed. Removing the cache (fetchPolicy=no-cache) solves the problem but we want to use it.
Do you know what can cause the nested fragment data to be null in this situation or similar?
Here is a query example that resemble our query:
query MyData($myParam: String!) {
getMyData(myParam: $myParam) {
categories {
catOne {
...MyFragmentOne
}
catTwo {
...MyFragmentOne
}
catThree {
...MyFragmentOne
}
}
brands {
brandOne {
...Brand
}
BrandTwo {
...Brand
}
BrandThree {
...Brand
}
}
}
}
fragment Brand on Brand {
id
name
keywords {
...Keywords
}
}
fragment Keywords on Keywords {
lang1
lang2
}`
Keywords is the data fragment returning null from the cache,
Versions I am are experiencing this in React Native using version ‘3.3.19’, I also tested using ‘3.4’ and the latest ‘3.6.9’ with the same result.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (3 by maintainers)
Top GitHub Comments
I also wasted hours before figuring out the missing possibleTypes config.
Ah ok. If any of those fragments use a type that implements an interface, or is part of a union, then adding
possibleTypes
might help. If you’re not using any unions or interfaces then I’m not sure what’s wrong.