Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix (defer): deferred fragment condition evaluation #353

Conversation

calvincestari
Copy link
Member

Conditions on a deferred fragment were not correctly being evaluated during field collection. This meant that deferred fragments would always be collected into _deferredFragments regardless of any condition. It's now fixed and deferred fragments are not collected if the condition would evaluate to false meaning the deferred fragment should never be expected to be received.

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This behavior is still wrong I think. If the conditions evaluate to false, the fragment will still be executed, it just won't be deferred. We need to treat it as a non-deferred fragment in that case, not ignore it completely.

@calvincestari
Copy link
Member Author

Yes, you're right. 🤦‍♂️

I'll correct this when I'm back on Monday.

@calvincestari
Copy link
Member Author

@AnthonyMDev this is now fixed with an additional test to ensure that a missingValue error is thrown during execution if the deferred data is not present with a false condition.

Copy link
Contributor

@AnthonyMDev AnthonyMDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now! Minor suggestions on the implementation, but the functionality is correct.

apollo-ios/Sources/Apollo/FieldSelectionCollector.swift Outdated Show resolved Hide resolved
apollo-ios/Sources/Apollo/FieldSelectionCollector.swift Outdated Show resolved Hide resolved
calvincestari and others added 2 commits May 13, 2024 14:19
Co-authored-by: Anthony Miller <anthonymdev@gmail.com>
@calvincestari calvincestari merged commit ea6311c into feature/defer-execution-networking May 13, 2024
16 checks passed
@calvincestari calvincestari deleted the defer/fix-defer-fragment-condition-evaluation branch May 13, 2024 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants