Handle multiple composable directives from the same spec#3086
Merged
tninesling merged 3 commits intotninesling/demand-control-directives-without-joinfrom Jul 17, 2024
Merged
Conversation
…osed from the same spec by enumerating them in link imports
|
|
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. |
clenfest
reviewed
Jul 17, 2024
clenfest
reviewed
Jul 17, 2024
clenfest
approved these changes
Jul 17, 2024
Contributor
clenfest
left a comment
There was a problem hiding this comment.
Two minor comments, but otherwise LGTM.
36d6c71
into
tninesling/demand-control-directives-without-join
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR targets the branch of an existing open PR. The main difference is that this one combines the new
@costand@listSizedirectives are combined into the same spec. This required a small update to how the supergraph schema is prepared.When a directive spec definition is imported by a subgraph, it was previously included in the supergraph without an import argument. So a subgraph with
@link(url: "https://specs.apollo.dev/cost/v0.1", import: ["@cost"]), is translated to the supergraph as@link(url: "https://specs.apollo.dev/cost/v0.1"). If multiple imports are included, the supergraph wouldn't get any of them. With this change, the supergraph now gets an equivalent@link(url: "https://specs.apollo.dev/cost/v0.1", import: ["@cost"]).Renaming
The core/link directive can have an argument called "as" to rename the directive from a spec. This would take a subgraph import
@link(url: "https://specs.apollo.dev/cost/v0.1", import: [{ name: "@cost", as: "@renamedCost" }]), and translate it to@link(url: "https://specs.apollo.dev/cost/v0.1", as: "renamedCost"). With this change, the supergraph now gets an equivalent@link(url: "https://specs.apollo.dev/cost/v0.1", import: [{ name: "@cost", as: "@renamedCost" }]).Import aggregation
As we add directive spec features to the supergraph, we check for existing links with the same feature version (both the link identity and the version must match). If one is found, we append the new directive to the existing list of imports.