Support graphql oneOf directive without composeDirective#306
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for composing the built-in @oneOf directive on input object types during supergraph composition. It updates the subgraph state builder to parse @oneOf on input objects, propagates this state through the supergraph composition AST, and outputs the directive in the resulting supergraph and public SDLs. Additionally, a skipApolloBuildCheck option was added to the test kit to bypass Apollo Gateway validation when needed. Feedback on the changes highlights two issues: a leftover test.only modifier in the new test file that would cause other tests to be skipped, and a leftover console.log debugging statement in validate-state.ts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
fc88b3d to
362d87c
Compare
| }); | ||
|
|
||
| test("guild composition supports composing built-in directive (@oneOf)", () => { | ||
| api.runIf("guild", () => { |
There was a problem hiding this comment.
only run for guild b/c others dont support atm
| ) { | ||
| getOrCreateInputObjectType(state, typeName).isOneOf = | ||
| true; | ||
| const oneOfDirective = getOrCreateDirective(state, 'oneOf'); |
There was a problem hiding this comment.
must ensure the definition is added or else Supergraph.build fails because the internal version of graphql it's using is out of date
|
Few things:
|
Apollo doesn't support oneOf because they are using an out dated version of graphql.
This PR adds functionality to keep the oneOf directives through composition and adds a test to ensure this works.
This avoids having to unnecessarily add
@composeDirectivefor@oneOf.@composeDirectiveshould be reserved for custom directives instead of native directives.