Skip to content

Commit cbd919b

Browse files
cynthiaqianCynthia Qian
andauthored
Fixes SchemaDiff Bug where unchanged deprecated enum marked DEPRECATION_ADDED (graphql-java#2826)
* Fixes SchemaDiff Bug where an unchanged deprecated enum is marked DEPRECATION_ADDED * Update SchemaDiffTest.groovy Co-authored-by: Cynthia Qian <cynthiaq@twitter.com>
1 parent 8c2232a commit cbd919b

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/main/java/graphql/schema/diff/SchemaDiff.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ private void checkEnumType(DiffCtx ctx, EnumTypeDefinition oldDef, EnumTypeDefin
477477
.components(enumName)
478478
.reasonMsg("The new API has added a new enum value '%s'", enumName)
479479
.build());
480-
} else if (isDeprecated(newDefinitionMap.get(enumName))) {
480+
} else if (isDeprecated(newDefinitionMap.get(enumName)) && !isDeprecated(oldEnum)) {
481481
ctx.report(DiffEvent.apiDanger()
482482
.category(DiffCategory.DEPRECATION_ADDED)
483483
.typeName(oldDef.getName())
@@ -917,4 +917,4 @@ private static String capitalize(String name) {
917917
private String mkDotName(String... objectNames) {
918918
return String.join(".", objectNames);
919919
}
920-
}
920+
}

src/test/groovy/graphql/schema/diff/SchemaDiffTest.groovy

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,18 @@ class SchemaDiffTest extends Specification {
485485

486486
}
487487

488+
def "deprecated fields are unchanged"() {
489+
def schema = TestUtil.schemaFile("diff/" + "schema_deprecated_fields_new.graphqls", wireWithNoFetching())
490+
DiffSet diffSet = DiffSet.diffSet(schema, schema)
491+
492+
def diff = new SchemaDiff()
493+
diff.diffSchema(diffSet, chainedReporter)
494+
495+
expect:
496+
reporter.dangerCount == 0
497+
reporter.breakageCount == 0
498+
}
499+
488500
def "field was deprecated"() {
489501
DiffSet diffSet = diffSet("schema_deprecated_fields_new.graphqls")
490502

0 commit comments

Comments
 (0)