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

RFC: incremental delivery: without branching, with deduplication #3886

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

yaacovCR
Copy link
Contributor

@yaacovCR yaacovCR commented Apr 24, 2023

This in the main PR implements the major ideas from the latest incremental delivery proposal, graphql/defer-stream-wg#69 which is centered around the idea of deduplication of execution and delivery.

This PR is part of the following stack:

#3886 = main PR (this PR!) switching to deduplication of execution/delivery
#3897 = adds pending
#3911 = adds helpers to resolvers to further delay execution of deferred fields or manage concurrency
#3895 = consolidates payloads

TODO:
[x] convert existing tests
[x] error handling
[x] filter late nulls correctly
[x] defer/streams interactions
[x] completed
[x] pending
[ ] ids and subpaths instead of paths
[ ] even more tests?

@netlify
Copy link

netlify bot commented Apr 24, 2023

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit 4ff4d05
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/64e771075ad340000855aa59
😎 Deploy Preview https://deploy-preview-3886--compassionate-pike-271cb3.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link

Hi @yaacovCR, I'm @github-actions bot happy to help you with this PR 👋

Supported commands

Please post this commands in separate comments and only one per comment:

  • @github-actions run-benchmark - Run benchmark comparing base and merge commits for this PR
  • @github-actions publish-pr-on-npm - Build package from this PR and publish it on NPM

@yaacovCR yaacovCR force-pushed the next branch 13 times, most recently from 0e36b36 to d4f1dc1 Compare April 28, 2023 08:12
@yaacovCR yaacovCR force-pushed the next branch 14 times, most recently from 8cb6f27 to a62d71e Compare May 4, 2023 19:07
@yaacovCR yaacovCR force-pushed the next branch 3 times, most recently from afe9880 to d59e215 Compare June 16, 2023 08:38
yaacovCR added a commit that referenced this pull request Jun 17, 2023
extracted from #3886

depends on #3903

more refactors from the without-branching branch, a bit more fundamental
than #3891

[set as patch release because it does have an observable effect on the
number of payloads, see below]

= iterate only through completed items
= remove extra ticks by making the publisher manage changes to its state
synchronously.
= use children array instead of promises to manage hierarchy
= have IncrementalPublisher instantiate new IncrementalDataRecords

= The new publisher sometimes cause an empty `{ hasNext: false }` to be
emitted. In particular, because the publisher is faster than it was, it
may emit a stream result before the stream's asynchronous iterator has
completed.
= The new publisher may sometimes reduce the number of `{ hasNext: false
}` records that are emitted. For example, when errors on the initial
result filter all subsequent results, this now happens synchronously,
and so the publisher knows immediately that there are no subsequent
results, such that there is no need for an empty final payload.
@yaacovCR yaacovCR force-pushed the next branch 6 times, most recently from 18549b1 to 1b1ca5b Compare July 5, 2023 12:36
yaacovCR added a commit that referenced this pull request Jul 6, 2023
…nces (#3929)

as memory then cannot be freed

This affects both the existing branching executor on main as well as the
non-branching, deduplicated version in #3886

We want to ensure that after an incremental result is sent to the
client, no subsequent results reference this result so that garbage
collection can free the memory associated with the result. To effect
this, two changes are required:

1. Prior to this change, we performed filtering by modifying the
children stored on a parent; now we add a flag on the filtered item
itself, so that we no longer need a backreference from child to parent.
2. We no longer store a permanent reference on the ExecutionContext to
the children of the initial result. Rather, we have the
IncrementalPublisher provide a new InitialResultRecord that carries its
own errors and children properties.
@yaacovCR yaacovCR force-pushed the next branch 4 times, most recently from 2253d69 to 272c52e Compare July 6, 2023 02:06
@yaacovCR yaacovCR force-pushed the next branch 2 times, most recently from 0dc7172 to d3b835e Compare July 16, 2023 12:32
@yaacovCR
Copy link
Contributor Author

Merging to implement graphql/defer-stream-wg#69

@yaacovCR yaacovCR merged commit 00e2b50 into graphql:main Aug 24, 2023
21 checks passed
@yaacovCR yaacovCR deleted the next branch August 24, 2023 19:55
sakesun pushed a commit to sakesun/graphql-js that referenced this pull request Sep 1, 2023
The `incremental` array is the actual data to be applied to the response, while the `completed` array return "metadata" about the execution, used to inform clients that defers are being executed and when all fields for that defer have been delivered.

To ensure consistency, clients are expected to process all objects in the `incremental` array for a given payload before re-rendering the associated UIs.

See graphql/defer-stream-wg#69 for full details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: breaking change 💥 implementation requires increase of "major" version number
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants