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

defer: Refactor execution for deferred fragment cache reads #390

Merged

Conversation

calvincestari
Copy link
Member

@calvincestari calvincestari commented Jun 14, 2024

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.

@calvincestari calvincestari force-pushed the defer/cache-read-execution branch from d25bb8d to 539394f Compare June 17, 2024 19:23
if executionSource.shouldAttemptDeferredFragmentExecution {
for deferredFragment in groupedFields.deferredFragments {
guard let fragmentType = groupedFields.cachedFragmentIdentifiers[deferredFragment] else {
info.deferredFragments.insert(deferredFragment)
Copy link
Member Author

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.

@calvincestari calvincestari force-pushed the defer/cache-read-execution branch from d6d1292 to 0e63ba9 Compare June 18, 2024 19:33
@calvincestari calvincestari marked this pull request as ready for review June 19, 2024 02:50
@calvincestari calvincestari linked an issue Jun 19, 2024 that may be closed by this pull request
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 was a lot of effort to get across the finish line. Great work Calvin! The tests looks great too!

@calvincestari calvincestari merged commit 278efa4 into feature/defer-execution-networking Jun 20, 2024
17 checks passed
@calvincestari calvincestari deleted the defer/cache-read-execution branch June 20, 2024 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for incremental cache reads
2 participants