@@ -89,6 +89,12 @@ const (
8989 InputFieldTypeChanged ChangeType = "INPUT_FIELD_TYPE_CHANGED"
9090 // ObjectTypeInterfaceAdded Object Type Interface Added
9191 ObjectTypeInterfaceAdded ChangeType = "OBJECT_TYPE_INTERFACE_ADDED"
92+ // InputFieldDeprecationAdded Field Deprecation Added
93+ InputFieldDeprecationAdded ChangeType = "INPUT_FIELD_DEPRECATION_ADDED"
94+ // InputFieldDeprecationRemoved Field Deprecation Removed
95+ InputFieldDeprecationRemoved ChangeType = "INPUT_FIELD_DEPRECATION_REMOVED"
96+ // InputFieldDeprecationReasonChanged Field Deprecation Reason Changed
97+ InputFieldDeprecationReasonChanged ChangeType = "INPUT_FIELD_DEPRECATION_REASON_CHANGED"
9298 // ObjectTypeInterfaceRemoved Object Type Interface Removed
9399 ObjectTypeInterfaceRemoved ChangeType = "OBJECT_TYPE_INTERFACE_REMOVED"
94100 // SchemaQueryTypeChanged Schema Query Type Changed
@@ -624,14 +630,18 @@ func checkEnumValueDeprecationChanged(oDef *ast.Definition, nv *ast.EnumValueDef
624630 position : nv .Position ,
625631 })
626632 }
627- if oDep != nil && nDep != nil && oDep .Arguments .ForName ("reason" ) != nDep .Arguments .ForName ("reason" ) {
628- changes = append (changes , & Change {
629- changeType : EnumValueDeprecationReasonChanged ,
630- criticalityLevel : NonBreaking ,
631- message : fmt .Sprintf ("Enum value '%s' deprecation reason changed in enum '%s' " , ov .Name , oDef .Name ),
632- path : fmt .Sprintf ("%s.%s" , oDef .Name , ov .Name ),
633- position : nv .Position ,
634- })
633+ if oDep != nil && nDep != nil {
634+ oReason := oDep .Arguments .ForName ("reason" )
635+ nReason := nDep .Arguments .ForName ("reason" )
636+ if oReason != nil && nReason != nil && oReason .Value .String () != nReason .Value .String () {
637+ changes = append (changes , & Change {
638+ changeType : EnumValueDeprecationReasonChanged ,
639+ criticalityLevel : NonBreaking ,
640+ message : fmt .Sprintf ("Enum value '%s' deprecation reason changed in enum '%s' " , ov .Name , oDef .Name ),
641+ path : fmt .Sprintf ("%s.%s" , oDef .Name , ov .Name ),
642+ position : nv .Position ,
643+ })
644+ }
635645 }
636646 return changes
637647}
@@ -835,31 +845,47 @@ func checkFieldDeprecationChanged(oDef *ast.Definition, nf *ast.FieldDefinition,
835845 oDep := of .Directives .ForName (deprecatedDirective )
836846 nDep := nf .Directives .ForName (deprecatedDirective )
837847 if oDep == nil && nDep != nil {
848+ changeType := FieldDeprecationAdded
849+ if oDef .Kind == ast .InputObject {
850+ changeType = InputFieldDeprecationAdded
851+ }
838852 changes = append (changes , & Change {
839- changeType : FieldDeprecationAdded ,
853+ changeType : changeType ,
840854 criticalityLevel : Dangerous ,
841855 message : fmt .Sprintf ("Field '%s.%s' deprecated in %s " , oDef .Name , of .Name , oDef .Kind ),
842856 path : fmt .Sprintf ("%s.%s" , oDef .Name , of .Name ),
843857 position : nf .Position ,
844858 })
845859 }
846860 if oDep != nil && nDep == nil {
861+ changeType := FieldDeprecationRemoved
862+ if oDef .Kind == ast .InputObject {
863+ changeType = InputFieldDeprecationRemoved
864+ }
847865 changes = append (changes , & Change {
848- changeType : FieldDeprecationRemoved ,
866+ changeType : changeType ,
849867 criticalityLevel : Dangerous ,
850868 message : fmt .Sprintf ("Field '%s.%s' deprecation removed in %s " , oDef .Name , of .Name , oDef .Kind ),
851869 path : fmt .Sprintf ("%s.%s" , oDef .Name , of .Name ),
852870 position : nf .Position ,
853871 })
854872 }
855- if oDep != nil && nDep != nil && oDep .Arguments .ForName ("reason" ) != nDep .Arguments .ForName ("reason" ) {
856- changes = append (changes , & Change {
857- changeType : FieldDeprecationReasonChanged ,
858- criticalityLevel : NonBreaking ,
859- message : fmt .Sprintf ("Field '%s.%s' deprecation reason changed in %s " , oDef .Name , of .Name , oDef .Kind ),
860- path : fmt .Sprintf ("%s.%s" , oDef .Name , of .Name ),
861- position : nf .Position ,
862- })
873+ if oDep != nil && nDep != nil {
874+ oReason := oDep .Arguments .ForName ("reason" )
875+ nReason := nDep .Arguments .ForName ("reason" )
876+ if oReason != nil && nReason != nil && oReason .Value .String () != nReason .Value .String () {
877+ changeType := FieldDeprecationReasonChanged
878+ if oDef .Kind == ast .InputObject {
879+ changeType = InputFieldDeprecationReasonChanged
880+ }
881+ changes = append (changes , & Change {
882+ changeType : changeType ,
883+ criticalityLevel : NonBreaking ,
884+ message : fmt .Sprintf ("Field '%s.%s' deprecation reason changed in %s " , oDef .Name , of .Name , oDef .Kind ),
885+ path : fmt .Sprintf ("%s.%s" , oDef .Name , of .Name ),
886+ position : nf .Position ,
887+ })
888+ }
863889 }
864890 return changes
865891}
@@ -1004,6 +1030,8 @@ func changeInInputFields(oDef *ast.Definition, nDef *ast.Definition) []*Change {
10041030 position : nf .Position ,
10051031 })
10061032 }
1033+ //Check deprecation changes
1034+ changes = append (changes , checkFieldDeprecationChanged (oDef , nf , of )... )
10071035 //check change in field directives
10081036 changes = append (changes , changeInTypeFieldDirectives (of .Directives , nf .Directives , fmt .Sprintf ("%s.%s" , nDef .Name , nf .Name ), nf .Position )... )
10091037 }
0 commit comments