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

Progressive @override (composition only) #2879

Conversation

trevor-scheer
Copy link
Member

@trevor-scheer trevor-scheer commented Dec 6, 2023

Bump fed spec to v2.7
Bump join spec to v0.4

Add new optional label arg to @override which is a String.
Capture label in the supergraph via the new @join__field arg overrideLabel so these values can be used during query graph creation and query planning.

@trevor-scheer trevor-scheer requested a review from a team as a code owner December 6, 2023 19:27
Copy link

changeset-bot bot commented Dec 6, 2023

⚠️ No Changeset found

Latest commit: c0a3638

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codesandbox-ci bot commented Dec 6, 2023

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@trevor-scheer trevor-scheer force-pushed the trevor/progressive-override-composition branch from de91f3a to 4587eaf Compare December 6, 2023 19:30
@trevor-scheer trevor-scheer force-pushed the trevor/progressive-override-composition branch 2 times, most recently from 1f4badd to 6357424 Compare December 18, 2023 21:08
@trevor-scheer trevor-scheer force-pushed the trevor/progressive-override-composition branch from 6357424 to 1b913e7 Compare December 18, 2023 21:35
Comment on lines +240 to +241
.add(new JoinSpecDefinition(new FeatureVersion(0, 3), new FeatureVersion(2, 0)))
.add(new JoinSpecDefinition(new FeatureVersion(0, 4), new FeatureVersion(2, 7)));
Copy link
Contributor

Choose a reason for hiding this comment

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

My understanding of the effect of these lines is that:

  1. If the latest federation version seen in composition is between v2.0 and v2.6, then join spec v0.3 will be used.
  2. If the latest federation version seen in composition is v2.7 or higher, then join spec v0.4 will be used.

From #2528 it looks like we want to use the earliest version of join spec permissible (for new versions at least), to avoid immediately breaking gateways/routers if people upgrade composition and forget to upgrade gateway/router first.

Which is mostly fine, but it probably deserves a note in the changelog, since it means customers who want to test a new version of composition will need to additionally bump at least one subgraph to v2.7 if they want to really test it (otherwise the first subgraph team trying to using v2.7 may encounter the issues instead of the team asked to test compatibility).

@@ -1248,6 +1270,12 @@ class Merger {
overriddenSubgraphASTNode,
));
}

// capture an override label if it exists
Copy link
Contributor

@sachindshinde sachindshinde Dec 19, 2023

Choose a reason for hiding this comment

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

We might want to do some kind of validation on the label here (it's easier to relax validations in the future than to add them). For example, we could require that the label must either (1) start with a letter and consist of alphanumeric+dashes+underscore(+periods+slashes+colons if we feel like it), or (2) be of the form percent(x) where x is a number between 0 and 100 inclusive (maybe something like BigNumber from bignumber.js could help here). If you have any other syntax in mind for label we could use that too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call out. I don't think we need a lib for this but let me know if you think I've missed anything in how we handle floats.
cf27bcb

Copy link
Contributor

Choose a reason for hiding this comment

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

It was mainly to handle cases where JS Numbers lose precision and we don't faithfully copy the argument from subgraphs to supergraph, but if you're using 10 digits total (1-2 before the decimal point and 8 after), then JS Numbers should be able to faithfully represent that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool. I think capping at 8 decimal points makes for a reasonable usage requirement that's also simple to enforce and communicate on our end, so if you don't see any other issue here I'll keep as is.

@trevor-scheer trevor-scheer force-pushed the trevor/progressive-override-composition branch from 1ab7c53 to cf27bcb Compare January 2, 2024 20:26
@trevor-scheer trevor-scheer requested a review from a team as a code owner January 2, 2024 20:26
Copy link
Contributor

@sachindshinde sachindshinde left a comment

Choose a reason for hiding this comment

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

Just some minor things below. (You'll also want to update the changeset regarding testing strategy, as noted here.)

@@ -1248,6 +1270,12 @@ class Merger {
overriddenSubgraphASTNode,
));
}

// capture an override label if it exists
Copy link
Contributor

Choose a reason for hiding this comment

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

It was mainly to handle cases where JS Numbers lose precision and we don't faithfully copy the argument from subgraphs to supergraph, but if you're using 10 digits total (1-2 before the decimal point and 8 after), then JS Numbers should be able to faithfully represent that.

@trevor-scheer trevor-scheer merged this pull request into trevor/progressive-override Jan 8, 2024
14 checks passed
@trevor-scheer trevor-scheer deleted the trevor/progressive-override-composition branch January 8, 2024 20:01
trevor-scheer added a commit that referenced this pull request Jan 19, 2024
Add new optional `label` arg to `@override` which is a `String`.
Capture label in the supergraph via the new `@join__field` arg
`overrideLabel` so these values can be used during query graph creation
and query planning.
trevor-scheer added a commit that referenced this pull request Jan 20, 2024
Add new optional `label` arg to `@override` which is a `String`.
Capture label in the supergraph via the new `@join__field` arg
`overrideLabel` so these values can be used during query graph creation
and query planning.
trevor-scheer added a commit that referenced this pull request Jan 20, 2024
Add new optional `label` arg to `@override` which is a `String`. Capture
label in the supergraph via the new `@join__field` arg `overrideLabel`
so these values can be used during query graph creation and query
planning.

Reviewed in two separate PRs:
#2879
#2902

---------

Co-authored-by: Sachin D. Shinde <[email protected]>
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.

2 participants