Skip to content

Commit b5692e4

Browse files
andimarekbbakerman
authored andcommitted
bugfix: comments on nodes should not considered when comparing arguments, therefore using printCompact
1 parent c71950c commit b5692e4

2 files changed

Lines changed: 97 additions & 2 deletions

File tree

src/main/java/graphql/schema/idl/SchemaTypeChecker.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,8 @@ private void checkArgumentConsistency(String typeOfType, ObjectTypeDefinition ob
484484
for (int i = 0; i < interfaceArgs.size(); i++) {
485485
InputValueDefinition interfaceArg = interfaceArgs.get(i);
486486
InputValueDefinition objectArg = objectArgs.get(i);
487-
String interfaceArgStr = AstPrinter.printAst(interfaceArg);
488-
String objectArgStr = AstPrinter.printAst(objectArg);
487+
String interfaceArgStr = AstPrinter.printAstCompact(interfaceArg);
488+
String objectArgStr = AstPrinter.printAstCompact(objectArg);
489489
if (!interfaceArgStr.equals(objectArgStr)) {
490490
errors.add(new InterfaceFieldArgumentRedefinitionError(typeOfType, objectTypeDef, interfaceTypeDef, objectFieldDef, objectArgStr, interfaceArgStr));
491491
}

src/test/groovy/graphql/schema/idl/SchemaTypeCheckerTest.groovy

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package graphql.schema.idl
22

33
import graphql.GraphQLError
4+
import graphql.TestUtil
45
import graphql.TypeResolutionEnvironment
56
import graphql.language.StringValue
67
import graphql.schema.Coercing
@@ -1525,4 +1526,98 @@ class SchemaTypeCheckerTest extends Specification {
15251526
"UserInput" | '{ fieldNonNull: "str", fieldNestedInput: { street: "nestedStr"} }'
15261527
}
15271528

1529+
1530+
def "different field descriptions on interface vs implementation should not cause an error "() {
1531+
given:
1532+
def sdl = """
1533+
type Query { hello: String }
1534+
interface Customer {
1535+
"The display name of the customer"
1536+
displayName: String!
1537+
}
1538+
1539+
type PersonCustomer implements Customer {
1540+
"The display name of the customer. For persons, this is the first and last name."
1541+
displayName: String!
1542+
}
1543+
1544+
type CompanyCustomer implements Customer {
1545+
"The display name of the customer. For companies, this is the company name and its form."
1546+
displayName: String!
1547+
}"""
1548+
1549+
when:
1550+
def schema = TestUtil.schema(sdl);
1551+
1552+
then:
1553+
schema != null
1554+
1555+
}
1556+
1557+
def "different argument descriptions on interface vs implementation should not cause an error "() {
1558+
given:
1559+
def sdl = """
1560+
type Query { hello: String }
1561+
1562+
interface Customer {
1563+
displayName(
1564+
"interface arg"
1565+
arg: String
1566+
): String!
1567+
}
1568+
1569+
type PersonCustomer implements Customer {
1570+
displayName(
1571+
"impl arg 1"
1572+
arg: String
1573+
): String!
1574+
}
1575+
1576+
type CompanyCustomer implements Customer {
1577+
displayName(
1578+
arg: String
1579+
): String!
1580+
}"""
1581+
1582+
when:
1583+
def schema = TestUtil.schema(sdl);
1584+
1585+
then:
1586+
schema != null
1587+
1588+
}
1589+
1590+
def "different argument comments on interface vs implementation should not cause an error "() {
1591+
given:
1592+
def sdl = """
1593+
type Query { hello: String }
1594+
1595+
interface Customer {
1596+
displayName(
1597+
# interface arg
1598+
arg: String
1599+
): String!
1600+
}
1601+
1602+
type PersonCustomer implements Customer {
1603+
displayName(
1604+
# impl arg 1
1605+
arg: String
1606+
): String!
1607+
}
1608+
1609+
type CompanyCustomer implements Customer {
1610+
displayName(
1611+
arg: String
1612+
): String!
1613+
}"""
1614+
1615+
when:
1616+
def schema = TestUtil.schema(sdl);
1617+
1618+
then:
1619+
schema != null
1620+
1621+
}
1622+
15281623
}

0 commit comments

Comments
 (0)