Skip to content

Commit dcc2e30

Browse files
authored
Remove check for same set of interfaces per type on schema merge (#118)
* remove condition that merged types needs the same amount of interfaces * added a test to confirm merging of different sets of interfaces work * removing one test case from table, because the check is now removed
1 parent 6a0452e commit dcc2e30

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

merge.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,11 +232,6 @@ func mergeObjectTypes(schema *ast.Schema, previousDefinition *ast.Definition, ne
232232

233233
}
234234

235-
// make sure the 2 implement the same number of interfaces
236-
if err := mergeStringSliceEquivalent(previousDefinition.Interfaces, newDefinition.Interfaces); err != nil {
237-
return fmt.Errorf("object type does not implement a consistent set of interfaces. %s", err.Error())
238-
}
239-
240235
// make sure that the 2 directive lists are the same
241236
if err := mergeDirectiveListsEqual(previousDefinition.Directives, newDefinition.Directives); err != nil {
242237
return err

merge_test.go

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,6 @@ func TestMergeSchema_objectTypes(t *testing.T) {
265265
}
266266
`,
267267
},
268-
{
269-
"Conflicting Implements",
270-
`
271-
interface Foo {
272-
firstName: String
273-
}
274-
275-
type User implements Foo {
276-
firstName: String
277-
}
278-
`,
279-
`
280-
type User {
281-
firstName: String
282-
}
283-
`,
284-
},
285268
{
286269
"Conflicting declaration directives",
287270
`
@@ -922,3 +905,56 @@ func testMergeSchemas(t *testing.T, schema1 *ast.Schema, schema2Str string) (*as
922905

923906
return gateway.schema, err
924907
}
908+
909+
func TestMergeSchemaDifferentSetsOfInterfaces(t *testing.T) {
910+
// Thing of schema1 implements one interface
911+
// Thing of schema2 implements two interfaces
912+
913+
schema1, err := graphql.LoadSchema(
914+
//language=GRAPHQL
915+
`
916+
type Query {
917+
node(id: ID!): Node
918+
Thing(id: ID!): Thing
919+
}
920+
921+
interface Node {
922+
id: ID!
923+
}
924+
925+
type Thing implements Node {
926+
id: ID!
927+
foo: String!
928+
}
929+
`)
930+
assert.Nil(t, err)
931+
schema2, err := graphql.LoadSchema(
932+
//language=GRAPHQL
933+
`
934+
type Query {
935+
node(id: ID!): Node
936+
Thing(id: ID!): Thing
937+
}
938+
939+
interface Node {
940+
id: ID!
941+
}
942+
943+
interface MetaData {
944+
created_at: String!
945+
}
946+
947+
type Thing implements Node & MetaData {
948+
id: ID!
949+
bar: String!
950+
created_at: String!
951+
}
952+
`)
953+
assert.Nil(t, err)
954+
955+
_, err = New([]*graphql.RemoteSchema{
956+
{Schema: schema2, URL: "url1"},
957+
{Schema: schema1, URL: "url2"},
958+
})
959+
assert.Nil(t, err)
960+
}

0 commit comments

Comments
 (0)