@@ -4075,6 +4075,145 @@ describe('composition', () => {
40754075 const result = composeAsFed2Subgraphs ( [ subgraphA , subgraphB ] ) ;
40764076 assertCompositionSuccess ( result ) ;
40774077 } ) ;
4078+
4079+ it ( 'composes @requires references to @interfaceObject' , ( ) => {
4080+ const subgraph1 = {
4081+ name : 'A' ,
4082+ url : 'https://Subgraph1' ,
4083+ typeDefs : gql `
4084+
4085+ type T implements I @key(fields: "id") {
4086+ id: ID!
4087+ i1: U! @external
4088+ specific: U! @requires(fields: "i1 { u1 }")
4089+ }
4090+
4091+ interface I @key(fields: "id") {
4092+ id: ID!
4093+ i1: U!
4094+ }
4095+
4096+ type U @shareable {
4097+ u1: String
4098+ }
4099+
4100+ type Query {
4101+ example: T!
4102+ }
4103+ `
4104+ }
4105+
4106+ const subgraph2 = {
4107+ name : 'B' ,
4108+ url : 'https://Subgraph2' ,
4109+ typeDefs : gql `
4110+ type I @key(fields: "id") @interfaceObject {
4111+ id: ID!
4112+ i1: U!
4113+ }
4114+
4115+ type U @shareable {
4116+ u1: String
4117+ }
4118+ `
4119+ }
4120+
4121+ let result = composeAsFed2Subgraphs ( [ subgraph1 , subgraph2 ] ) ;
4122+ assertCompositionSuccess ( result ) ;
4123+ console . log ( result . supergraphSdl ) ;
4124+
4125+ expect ( result . supergraphSdl ) . toMatchString ( `
4126+ schema
4127+ @link(url: "https://specs.apollo.dev/link/v1.0")
4128+ @link(url: "https://specs.apollo.dev/join/v0.5", for: EXECUTION)
4129+ {
4130+ query: Query
4131+ }
4132+
4133+ directive @join__directive(graphs: [join__Graph!], name: String!, args: join__DirectiveArguments) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
4134+
4135+ directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
4136+
4137+ directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean, overrideLabel: String, contextArguments: [join__ContextArgument!]) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
4138+
4139+ directive @join__graph(name: String!, url: String!) on ENUM_VALUE
4140+
4141+ directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE
4142+
4143+ directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
4144+
4145+ directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
4146+
4147+ directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
4148+
4149+ interface I
4150+ @join__type(graph: A, key: "id")
4151+ @join__type(graph: B, key: "id", isInterfaceObject: true)
4152+ {
4153+ id: ID!
4154+ i1: U!
4155+ }
4156+
4157+ input join__ContextArgument {
4158+ name: String!
4159+ type: String!
4160+ context: String!
4161+ selection: join__FieldValue!
4162+ }
4163+
4164+ scalar join__DirectiveArguments
4165+
4166+ scalar join__FieldSet
4167+
4168+ scalar join__FieldValue
4169+
4170+ enum join__Graph {
4171+ A @join__graph(name: "A", url: "https://Subgraph1")
4172+ B @join__graph(name: "B", url: "https://Subgraph2")
4173+ }
4174+
4175+ scalar link__Import
4176+
4177+ enum link__Purpose {
4178+ """
4179+ \`SECURITY\` features provide metadata necessary to securely resolve fields.
4180+ """
4181+ SECURITY
4182+
4183+ """
4184+ \`EXECUTION\` features provide metadata necessary for operation execution.
4185+ """
4186+ EXECUTION
4187+ }
4188+
4189+ type Query
4190+ @join__type(graph: A)
4191+ @join__type(graph: B)
4192+ {
4193+ example: T! @join__field(graph: A)
4194+ }
4195+
4196+ type T implements I
4197+ @join__implements(graph: A, interface: "I")
4198+ @join__type(graph: A, key: "id")
4199+ {
4200+ id: ID!
4201+ i1: U! @join__field(graph: A, external: true)
4202+ specific: U! @join__field(graph: A, requires: "i1 { u1 }")
4203+ }
4204+
4205+ type U
4206+ @join__type(graph: A)
4207+ @join__type(graph: B)
4208+ {
4209+ u1: String
4210+ }
4211+ ` ) ;
4212+
4213+ // composes regardless of the subgraph order
4214+ result = composeAsFed2Subgraphs ( [ subgraph2 , subgraph1 ] ) ;
4215+ assertCompositionSuccess ( result ) ;
4216+ } )
40784217 } ) ;
40794218
40804219 describe ( '@authenticated' , ( ) => {
0 commit comments