Fields Dropped when using a Fragment
See original GitHub issueIntended outcome:
When querying with a fragment, the fields specified by the fragment should not be undefined
.
Actual outcome:
Fields specified by a fragment will get completely dropped after running the merge
function. The rest of the query data is still there, even though returnPartialData
is false.
How to reproduce the issue:
https://github.com/dylanwulf/react-apollo-error-template/tree/fragment-dropping-fields
Please use branch fragment-dropping-fields
.
Versions
System:
OS: Windows 10 10.0.19042
Binaries:
Node: 14.16.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.21.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.12 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 91.0.4472.101
Edge: Spartan (44.19041.1023.0), Chromium (91.0.864.48)
npmPackages:
@apollo/client: ^3.3.20 => 3.3.20
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Nesting fragment spreads on union drops fields #8177 - GitHub
Drops all the fields except the typename in the data returned from useQuery. Notably, the data does pass through the network tab (when...
Read more >Layout fields of fragment are NULL on initialization
I have photos of fields of two fragments I use, maby some of you know what that data can tell about status of...
Read more >IP Fragmentation in Detail - Packet Pushers
Fragmentation's operation relies upon three IP header fields (32 bits in total), all of which will have very different values in the fragments ......
Read more >Android Fragments Common Queries & Common Mistakes
Most of people create connection between two fragments using activity, few people pass interface listeners as a parameter to fragment which ...
Read more >Saving state with fragments - Android Developers
Generated when the fragment is created for the very first time. randomGoodDeed is saved to ensure that users see the same random good...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@dylanwulf Thanks for the reproduction!
This took me a while to track this down, so I know your pain, but your
paginatedQueryMerge
function seems to be dropping the__typename
field fromFruitsQueryResult
andVegetablesQueryResult
objects, despite merging the rest of the fields successfully:If the
__typename: "FruitsQueryResult"
field is lost, then when the client reads from the cache for the final results (afterfetchMore
finishes), the...ResultFragment
in that query fails to match/spread, because the cache can’t verify theFruitsQueryResult
object is a subtype ofQueryResult
without knowing its__typename
.Maybe there’s an opportunity for a warning here? Preserving
__typename
fields is probably worth some console noise. Let me know if you have any thoughts about how that might work!@benjamn Wow, I feel dumb now 😅. Thank you for getting back to me so quickly! Really appreciate it. As for the warning idea, I definitely would be in support of something like that. Not really sure about the exact details of how it should work though. I’ll leave this issue open in case you want to use it to track the warning idea, but otherwise feel free to close! Thanks again!