fix: preserve composed directives with executable locations in supergraph#297
Open
adambenhassen wants to merge 5 commits intomainfrom
Open
fix: preserve composed directives with executable locations in supergraph#297adambenhassen wants to merge 5 commits intomainfrom
adambenhassen wants to merge 5 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request ensures that composed directives are preserved in the supergraph SDL, even when they contain executable locations and are defined in only one subgraph. The logic in src/supergraph/state.ts was updated to prevent stripping directives marked as composed. Additionally, new test cases were added to verify this behavior for various directive locations, including executable and mixed locations. I have no feedback to provide as there were no review comments to evaluate.
Contributor
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.
Summary
@composeDirectivewas not preserving directive definitions in the supergraph when the directive only had executable locations (QUERY,MUTATION,FIELD,VARIABLE_DEFINITION). Directives with schema-level locations (OBJECT,FIELD_DEFINITION) worked correctly.This affected users trying to use
@composeDirectiveto promote operation-level directives (e.g.@mcpTool,@mcpDescription) into the supergraph for app deployment validation.Root cause
The
build()function strips executable directives that aren't shared across all subgraphs. There was already a carve-out for composed directives at the location-filtering level, but it only protected schema-level locations. Composed directives with purely executable locations still entered the stripping loop and were deleted because they failed the cross-subgraph identity check.Proposed fix
Skip the entire executable directive stripping block for composed directives. If a directive is marked via
@composeDirective, the user explicitly requested it in the supergraph, the composition should not strip it.Tests added