Skip to content

fix(compostition): Fix port of @composeDirective#9164

Open
sachindshinde wants to merge 4 commits intodevfrom
sachin/fix-compose-directive
Open

fix(compostition): Fix port of @composeDirective#9164
sachindshinde wants to merge 4 commits intodevfrom
sachin/fix-compose-directive

Conversation

@sachindshinde
Copy link
Copy Markdown
Contributor

@sachindshinde sachindshinde commented Apr 9, 2026

While reviewing #8936, I noticed some issues in the PR, but there were also more issues in the surrounding code for @composeDirective. This PR brings the Rust port more inline with the JS code (including the changes that #8936 were trying to port over; the tests from that PR have been pulled into this one). Note that the tests overall seem to be a bit different, and I'm still in the middle of double-checking them, but the non-test code should be ready for review.

@sachindshinde sachindshinde requested a review from a team as a code owner April 9, 2026 20:06
@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian bot commented Apr 9, 2026

✅ Docs preview has no changes

The preview was not built because there were no changes.

Build ID: 983cd304143e46a4dd01dfb7
Build Logs: View logs


✅ AI Style Review — No Changes Detected

No MDX files were changed in this pull request.

Review Log: View detailed log

This review is AI-generated. Please use common sense when accepting these suggestions, as they may not always be accurate or appropriate for your specific context.

@sachindshinde sachindshinde force-pushed the sachin/fix-compose-directive branch from 5a5c008 to be72cb3 Compare April 9, 2026 20:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

@sachindshinde, please consider creating a changeset entry in /.changesets/. These instructions describe the process and tooling.

@sachindshinde sachindshinde force-pushed the sachin/fix-compose-directive branch from 5dcf94a to b809f3d Compare April 10, 2026 17:21
Copy link
Copy Markdown
Member

@dariuszkuc dariuszkuc left a comment

Choose a reason for hiding this comment

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

Looks good just a couple questions around tests

);

let result = compose(vec![subgraph_a, subgraph_b]).unwrap();
println!("{:?}", result.hints());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

leftover from debugging?

pub spec_alias: Option<Name>,
pub imports: Vec<Arc<Import>>,
pub purpose: Option<Purpose>,
pub line_column_range: Option<Range<LineColumn>>,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

note for self: this is added so we can calculate location information for subgraph errors

let imports = directives
.iter()
.map(|(original, alias)| {
.map(|(alias, original)| {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

good catch!

@@ -1687,18 +1684,14 @@ format!("Field \"{field}\" of {} type \"{}\" is defined in some but not all subg
// We should skip the supergraph specific directives, that is the @core and @join directives.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you update this comment to @link and @join directives?

);
let subgraph_b = generate_subgraph(
"subgraphB",
r#"@link(url: "https://specs.custom.dev/foo/v1.1", import: ["@bar"])"#,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just wondering whether we should be explicit with import: ["@bar", "@foo"] here (or maybe use different custom directive names as @foo is implicitly handled as its name matches the spec name)

r#"@composeDirective(name: "@foo")"#,
r#"
directive @foo(name: String!) on FIELD_DEFINITION
directive @bar(name: String!) on FIELD_DEFINITION
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

should this only include @foo definition and skip the @bar (and vice versa in subgraph_b)?

r#"@composeDirective(name: "@foo")"#,
r#"
directive @foo(name: String!) on FIELD_DEFINITION
directive @bar(name: String!) on FIELD_DEFINITION
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

drop the @bar

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