Skip to content

refactor(incremental): set pending result id during execution #4117

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

Closed
wants to merge 7 commits into from

Conversation

yaacovCR
Copy link
Contributor

This makes id an immutable property of each pending result, reducing the need to track these ids / lazily create them within the publisher.

Spec changes

This would change the language in the specification around creating a pending result to be something like:

Let {id} be a unique identifier for this new Deferred Fragment.
Let {path} and {label} be the path and label....
Let {newDeferredFragment} be an unordered map containing {id}, {path} and {label}

And retrieving the {id} to be as simple as:

Let {id} be the corresponding entry on {deferredFragment}.

As opposed to the current way of doing things, where we kind of hand-wave and just write when retrieving the {id} for the first time (i.e. when preparing the entry within the pending list to send to the client:

Let {id} be a unique identifier for this new Deferred Fragment.

And then when using it later within incremental and completed:

Let {id} be the unique identifier for this Deferred Fragment.

Implementation Differences

With this change, empty and filtered deferred fragments will lead to "missing" ids and id ordering will now depend on timing/early execution. The id by the specification are opaque strings so that this is not a specification concern. It's not a practical concern either -- in fact, one could argue that this wierdness is actually beneficial, in that if the ids were always sequential, clients might think that the spec says they should be, but the spec actually says they are opaque strings.

A practical concern, however, is that every future change to internals which results in a different execution ordering (presumably rare, but possible) may result in a change to these identifiers, which could end up breaking library users who have hardcoded their tests utilizing graphql-js with specific identifiers. This seems bad.

Along a very minor similar vein, it is unclear what to label this change. It's just polish, really, but it unfortunately does have an observable difference. Presumably we would have to bump it up to patch-release worthy, which would translate to the bug-fix label.1

My Conclusion

I am leaning against this change.

Footnotes

  1. Of course, the actual release type doesn't matter, as we are on alpha and have breaking changes already within our alpha, as one might expect. It's the ambiguity of what to label this change that is parallel to the practical concern above, the theoretical question of how to release if this was the only change in the queue, not actually how we would perform the next release.

return newPending alongside incremental results
@yaacovCR yaacovCR requested a review from robrichard June 20, 2024 10:19
Copy link

netlify bot commented Jun 20, 2024

Deploy Preview for compassionate-pike-271cb3 ready!

Name Link
🔨 Latest commit c4524ff
🔍 Latest deploy log https://app.netlify.com/sites/compassionate-pike-271cb3/deploys/667c26ca3cddad0008dc01e7
😎 Deploy Preview https://deploy-preview-4117--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.

@yaacovCR yaacovCR marked this pull request as ready for review June 20, 2024 10:19
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 set-id-during-execution branch 2 times, most recently from af173ac to be46ece Compare June 20, 2024 10:38
@yaacovCR yaacovCR force-pushed the set-id-during-execution branch from be46ece to d4ef4ed Compare June 26, 2024 14:27
yaacovCR added 4 commits June 26, 2024 17:31
when early execution is disabled, deferred grouped field sets should start immediately if and only if one of their deferred fragments is released as pending

see: graphql/defer-stream-wg#84
This makes id an immutable property of each pending result, reducing the need to track these ids / lazily create them within the publisher.

Empty and filtered deferred fragments will lead to "missing" ids and id ordering will now depend on timing/early execution. The id by the specification are opaque strings so that this is not a concern.
@yaacovCR yaacovCR force-pushed the set-id-during-execution branch from d4ef4ed to c4524ff Compare June 26, 2024 14:33
@yaacovCR
Copy link
Contributor Author

yaacovCR commented Jul 3, 2024

closing for now after discussing with @robrichard offline => we can revisit later if need be

@yaacovCR yaacovCR closed this Jul 3, 2024
@yaacovCR yaacovCR deleted the set-id-during-execution branch July 3, 2024 19:32
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.

1 participant