Skip to content

Handle multiple composable directives from the same spec#3086

Merged
tninesling merged 3 commits intotninesling/demand-control-directives-without-joinfrom
tninesling/combine-cost-specs
Jul 17, 2024
Merged

Handle multiple composable directives from the same spec#3086
tninesling merged 3 commits intotninesling/demand-control-directives-without-joinfrom
tninesling/combine-cost-specs

Conversation

@tninesling
Copy link
Copy Markdown
Contributor

Overview

This PR targets the branch of an existing open PR. The main difference is that this one combines the new @cost and @listSize directives 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.

@tninesling tninesling requested a review from a team as a code owner July 16, 2024 21:27
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jul 16, 2024

⚠️ No Changeset found

Latest commit: cffdc9c

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

@codesandbox-ci
Copy link
Copy Markdown

codesandbox-ci bot commented Jul 16, 2024

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.

@tninesling tninesling requested a review from clenfest July 16, 2024 21:28
Copy link
Copy Markdown
Contributor

@clenfest clenfest left a comment

Choose a reason for hiding this comment

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

Two minor comments, but otherwise LGTM.

@tninesling tninesling merged commit 36d6c71 into tninesling/demand-control-directives-without-join Jul 17, 2024
@tninesling tninesling deleted the tninesling/combine-cost-specs branch July 17, 2024 17:45
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