Skip to content

SchemaDiff has no special/helpful handling for directives like @deprecated #1504

@grrttedwards

Description

@grrttedwards

Version 11.0
Currently, SchemaDiff does not make any distinctions for changes which involve @deprecated directives. This may be intended, but I was considering a use case where this is important information for an automated service registry. For example, the following change generates no meaningful events:

type Query { foo: TypeA } 
-type TypeA { abc: String xyz: Int }
---
type Query { foo: TypeA } 
+type TypeA { abc: String @deprecated xyz: Int }

Output:

14:22:26.799 [main] INFO - Infos count: 9
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='Examining operation 'Query' ...', level=INFO, category=null, typeName='Query', typeKind=Operation, fieldName=null}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='Examining type 'Query' ...', level=INFO, category=null, typeName='Query', typeKind=Object, fieldName=null}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'Query.foo' ...', level=INFO, category=null, typeName='Query', typeKind=Object, fieldName=foo}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='Examining type 'TypeA' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=null}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.abc' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=abc}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.xyz' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=xyz}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.abc' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=abc}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.xyz' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=xyz}
14:22:26.807 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'Query.foo' ...', level=INFO, category=null, typeName='Query', typeKind=Object, fieldName=foo}
14:22:26.808 [main] WARN - Danger count: 0
14:22:26.808 [main] ERROR - Breakage count: 0

In addition, it would be desirable to see a special handling of a breaking change involving a deprecated field. In the case of the automated service registry I mentioned, it's possible to allow such a breaking change only if the service had deprecated the field in a previous version. For example:

type Query { foo: TypeA } 
-type TypeA { abc: String @deprecated xyz: Int }
---
type Query { foo: TypeA } 
+type TypeA { xyz: Int }

Reports only a standard BREAKING change

14:29:52.811 [main] INFO - Infos count: 8
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='Examining operation 'Query' ...', level=INFO, category=null, typeName='Query', typeKind=Operation, fieldName=null}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='Examining type 'Query' ...', level=INFO, category=null, typeName='Query', typeKind=Object, fieldName=null}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'Query.foo' ...', level=INFO, category=null, typeName='Query', typeKind=Object, fieldName=foo}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='Examining type 'TypeA' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=null}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.abc' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=abc}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.xyz' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=xyz}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'TypeA.xyz' ...', level=INFO, category=null, typeName='TypeA', typeKind=Object, fieldName=xyz}
14:29:52.814 [main] INFO - DifferenceEvent{ reasonMsg='	Examining field 'Query.foo' ...', level=INFO, category=null, typeName='Query', typeKind=Object, fieldName=foo}
14:29:52.815 [main] WARN - Danger count: 0
14:29:52.815 [main] ERROR - Breakage count: 1
14:29:52.816 [main] ERROR - DifferenceEvent{ reasonMsg='The new API is missing the field 'TypeA.abc'', level=BREAKING, category=MISSING, typeName='TypeA', typeKind=Object, fieldName=abc}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions