fix: invalid public sdl for inaccessible interface type#198
Conversation
There was a problem hiding this comment.
Could not find a clever way of not having a second visit without changing the call signature of transformSupergraphToPublicSchema. 😄 I guess this is okay enough.
dotansimha
left a comment
There was a problem hiding this comment.
nice catch. @kamilkisiela @jdolle thoughts?
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## @theguild/federation-composition@0.20.2 ### Patch Changes - [#198](#198) [`1b98c17`](1b98c17) Thanks [@user!](https://github.com/User!), [@user!](https://github.com/User!)! - Fix public schema SDL in case a object type implements an inaccessible interface. Composing the following subgraph: ```graphql schema @link( url: "https://specs.apollo.dev/federation/v2.3" import: ["@inaccessible"] ) { query: Query } type Query { } interface Node @inaccessible { id: ID! } type User implements Node { id: ID! } ``` now result in the following valid public SDL: ```diff type Query { } - type User implements Node { + type User { id: ID! } ``` Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
There was a problem hiding this comment.
To avoid a full second pass youd need to keep track of where interfaces are used, then do a lookup based on the interface name to the nodes.
I understand why we have to do this, but I think this behavior is all a bit strange. We don't automatically clean up fields if they have a returnType that is made inaccessible.... Should we do that also?
|
@jdolle I think that is already done in a pre step as part of the supergraph validation and building. |
The public schema SDL is wrong when it implements an inaccessible interface type, it retains the interface implementation even though it is not part of the public schema.
See changeset for an example diff of what was fixed