-
Notifications
You must be signed in to change notification settings - Fork 61
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
defer: Refactor execution for deferred fragment cache reads #390
defer: Refactor execution for deferred fragment cache reads #390
Conversation
apollo-ios/Sources/Apollo/ExecutionSources/NetworkResponseExecutionSource.swift
Show resolved
Hide resolved
d25bb8d
to
539394f
Compare
if executionSource.shouldAttemptDeferredFragmentExecution { | ||
for deferredFragment in groupedFields.deferredFragments { | ||
guard let fragmentType = groupedFields.cachedFragmentIdentifiers[deferredFragment] else { | ||
info.deferredFragments.insert(deferredFragment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case that the fragment type cannot be found in the cache I think it's best that it remains 'deferred'; it's not going to break execution.
d6d1292
to
0e63ba9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was a lot of effort to get across the finish line. Great work Calvin! The tests looks great too!
apollo-ios/Sources/Apollo/ExecutionSources/NetworkResponseExecutionSource.swift
Show resolved
Hide resolved
278efa4
into
feature/defer-execution-networking
This changeset enables cache-based execution of operations that use
@defer
. Since there is only a single response from a cache read all available deferred fragments will be returned with the initial (partial) data. Any deferred fragments that cannot be fulfilled will remain as 'deferred' in the result.The executor now enumerates through deferred fragments that were collected into
_deferredFragments
, matches the identifier to a fragment cache entry, and attempts to immediately resolve the fragment fields. If successful then the deferred fragment is marked as fulfilled. If the deferred fragment cannot resolved because of something such as a missing field, then the fragment remains as 'deferred' in the result.