@@ -70,6 +70,7 @@ export type DangerousChangeType =
7070 ( typeof DangerousChangeType ) [ keyof typeof DangerousChangeType ] ;
7171
7272export const SafeChangeType = {
73+ DESCRIPTION_CHANGED : 'DESCRIPTION_CHANGED' as const ,
7374 TYPE_ADDED : 'TYPE_ADDED' as const ,
7475 OPTIONAL_INPUT_FIELD_ADDED : 'OPTIONAL_INPUT_FIELD_ADDED' as const ,
7576 OPTIONAL_ARG_ADDED : 'OPTIONAL_ARG_ADDED' as const ,
@@ -194,6 +195,15 @@ function findDirectiveChanges(
194195 } ) ;
195196 }
196197
198+ for ( const [ oldArg , newArg ] of argsDiff . persisted ) {
199+ if ( oldArg . description !== newArg . description ) {
200+ schemaChanges . push ( {
201+ type : SafeChangeType . DESCRIPTION_CHANGED ,
202+ description : `Description of @${ oldDirective . name } (${ oldDirective . name } ) has changed to "${ newArg . description } ".` ,
203+ } ) ;
204+ }
205+ }
206+
197207 if ( oldDirective . isRepeatable && ! newDirective . isRepeatable ) {
198208 schemaChanges . push ( {
199209 type : BreakingChangeType . DIRECTIVE_REPEATABLE_REMOVED ,
@@ -206,6 +216,13 @@ function findDirectiveChanges(
206216 } ) ;
207217 }
208218
219+ if ( oldDirective . description !== newDirective . description ) {
220+ schemaChanges . push ( {
221+ type : SafeChangeType . DESCRIPTION_CHANGED ,
222+ description : `Description of @${ oldDirective . name } has changed to "${ newDirective . description } ".` ,
223+ } ) ;
224+ }
225+
209226 for ( const location of oldDirective . locations ) {
210227 if ( ! newDirective . locations . includes ( location ) ) {
211228 schemaChanges . push ( {
@@ -256,6 +273,13 @@ function findTypeChanges(
256273 }
257274
258275 for ( const [ oldType , newType ] of typesDiff . persisted ) {
276+ if ( oldType . description !== newType . description ) {
277+ schemaChanges . push ( {
278+ type : SafeChangeType . DESCRIPTION_CHANGED ,
279+ description : `Description of ${ oldType . name } has changed to "${ newType . description } ".` ,
280+ } ) ;
281+ }
282+
259283 if ( isEnumType ( oldType ) && isEnumType ( newType ) ) {
260284 schemaChanges . push ( ...findEnumTypeChanges ( oldType , newType ) ) ;
261285 } else if ( isUnionType ( oldType ) && isUnionType ( newType ) ) {
@@ -328,14 +352,21 @@ function findInputObjectTypeChanges(
328352 `Field ${ oldType } .${ oldField . name } changed type from ` +
329353 `${ String ( oldField . type ) } to ${ String ( newField . type ) } .` ,
330354 } ) ;
331- } else {
355+ } else if ( oldField . type . toString ( ) !== newField . type . toString ( ) ) {
332356 schemaChanges . push ( {
333357 type : SafeChangeType . FIELD_CHANGED_KIND_SAFE ,
334358 description :
335359 `Field ${ oldType } .${ oldField . name } changed type from ` +
336360 `${ String ( oldField . type ) } to ${ String ( newField . type ) } .` ,
337361 } ) ;
338362 }
363+
364+ if ( oldField . description !== newField . description ) {
365+ schemaChanges . push ( {
366+ type : SafeChangeType . DESCRIPTION_CHANGED ,
367+ description : `Description of input-field ${ newType } .${ newField . name } has changed to "${ newField . description } ".` ,
368+ } ) ;
369+ }
339370 }
340371
341372 return schemaChanges ;
@@ -368,7 +399,7 @@ function findUnionTypeChanges(
368399function findEnumTypeChanges (
369400 oldType : GraphQLEnumType ,
370401 newType : GraphQLEnumType ,
371- ) : Array < BreakingChange | DangerousChange > {
402+ ) : Array < SchemaChange > {
372403 const schemaChanges = [ ] ;
373404 const valuesDiff = diff ( oldType . getValues ( ) , newType . getValues ( ) ) ;
374405
@@ -386,6 +417,15 @@ function findEnumTypeChanges(
386417 } ) ;
387418 }
388419
420+ for ( const [ oldValue , newValue ] of valuesDiff . persisted ) {
421+ if ( oldValue . description !== newValue . description ) {
422+ schemaChanges . push ( {
423+ type : SafeChangeType . DESCRIPTION_CHANGED ,
424+ description : `Description of enum value ${ oldType } .${ oldValue . name } has changed to "${ newValue . description } ".` ,
425+ } ) ;
426+ }
427+ }
428+
389429 return schemaChanges ;
390430}
391431
@@ -459,6 +499,13 @@ function findFieldChanges(
459499 `${ String ( oldField . type ) } to ${ String ( newField . type ) } .` ,
460500 } ) ;
461501 }
502+
503+ if ( oldField . description !== newField . description ) {
504+ schemaChanges . push ( {
505+ type : SafeChangeType . DESCRIPTION_CHANGED ,
506+ description : `Description of field ${ oldType } .${ oldField . name } has changed to "${ newField . description } ".` ,
507+ } ) ;
508+ }
462509 }
463510
464511 return schemaChanges ;
@@ -484,6 +531,7 @@ function findArgChanges(
484531 oldArg . type ,
485532 newArg . type ,
486533 ) ;
534+
487535 if ( ! isSafe ) {
488536 schemaChanges . push ( {
489537 type : BreakingChangeType . ARG_CHANGED_KIND ,
@@ -520,14 +568,21 @@ function findArgChanges(
520568 type : SafeChangeType . ARG_DEFAULT_VALUE_ADDED ,
521569 description : `${ oldType } .${ oldField . name } (${ oldArg . name } :) added a defaultValue ${ newValueStr } .` ,
522570 } ) ;
523- } else {
571+ } else if ( oldArg . type . toString ( ) !== newArg . type . toString ( ) ) {
524572 schemaChanges . push ( {
525573 type : SafeChangeType . ARG_CHANGED_KIND_SAFE ,
526574 description :
527575 `Argument ${ oldType } .${ oldField . name } (${ oldArg . name } :) has changed type from ` +
528576 `${ String ( oldArg . type ) } to ${ String ( newArg . type ) } .` ,
529577 } ) ;
530578 }
579+
580+ if ( oldArg . description !== newArg . description ) {
581+ schemaChanges . push ( {
582+ type : SafeChangeType . DESCRIPTION_CHANGED ,
583+ description : `Description of argument ${ oldType } .${ oldField . name } (${ oldArg . name } ) has changed to "${ newArg . description } ".` ,
584+ } ) ;
585+ }
531586 }
532587
533588 for ( const newArg of argsDiff . added ) {
0 commit comments