File tree Expand file tree Collapse file tree 2 files changed +59
-4
lines changed Expand file tree Collapse file tree 2 files changed +59
-4
lines changed Original file line number Diff line number Diff line change @@ -392,6 +392,54 @@ describe('findBreakingChanges', () => {
392
392
] ) ;
393
393
} ) ;
394
394
395
+ it ( 'should not flag args with the same type signature as breaking' , ( ) => {
396
+ const oldType = new GraphQLObjectType ( {
397
+ name : 'Type1' ,
398
+ fields : {
399
+ field1 : {
400
+ type : GraphQLInt ,
401
+ args : {
402
+ id : {
403
+ type : new GraphQLNonNull ( GraphQLInt ) ,
404
+ } ,
405
+ } ,
406
+ } ,
407
+ } ,
408
+ } ) ;
409
+
410
+ const newType = new GraphQLObjectType ( {
411
+ name : 'Type1' ,
412
+ fields : {
413
+ field1 : {
414
+ type : GraphQLInt ,
415
+ args : {
416
+ id : {
417
+ type : new GraphQLNonNull ( GraphQLInt ) ,
418
+ } ,
419
+ } ,
420
+ } ,
421
+ } ,
422
+ } ) ;
423
+
424
+ const oldSchema = new GraphQLSchema ( {
425
+ query : queryType ,
426
+ types : [
427
+ oldType ,
428
+ ]
429
+ } ) ;
430
+
431
+ const newSchema = new GraphQLSchema ( {
432
+ query : queryType ,
433
+ types : [
434
+ newType ,
435
+ ]
436
+ } ) ;
437
+
438
+ expect (
439
+ findArgChanges ( oldSchema , newSchema ) . breakingChanges
440
+ ) . to . eql ( [ ] ) ;
441
+ } ) ;
442
+
395
443
it ( 'should consider args that move away from NonNull as non-breaking' , ( ) => {
396
444
const oldType = new GraphQLObjectType ( {
397
445
name : 'Type1' ,
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ import {
16
16
GraphQLInterfaceType ,
17
17
GraphQLObjectType ,
18
18
GraphQLUnionType ,
19
- getNullableType ,
20
19
} from '../type/definition' ;
21
20
22
21
import type { GraphQLNamedType , GraphQLFieldMap } from '../type/definition' ;
@@ -175,8 +174,17 @@ export function findArgChanges(
175
174
) ;
176
175
const newArgDef = newArgs [ newTypeArgIndex ] ;
177
176
177
+ const oldArgTypeName = getNamedType ( oldArgDef . type ) ;
178
+ const newArgTypeName = newArgDef ?
179
+ getNamedType ( newArgDef . type ) :
180
+ null ;
181
+
182
+ if ( ! oldArgTypeName ) {
183
+ return ;
184
+ }
185
+
178
186
// Arg not present
179
- if ( newTypeArgIndex < 0 ) {
187
+ if ( ! newArgTypeName ) {
180
188
breakingChanges . push ( {
181
189
type : BreakingChangeType . ARG_REMOVED ,
182
190
description : `${ oldType . name } .${ fieldName } arg ` +
@@ -185,8 +193,7 @@ export function findArgChanges(
185
193
186
194
// Arg changed type in a breaking way
187
195
} else if (
188
- oldArgDef . type !== newArgDef . type &&
189
- getNullableType ( oldArgDef . type ) !== newArgDef . type
196
+ oldArgTypeName . name !== newArgTypeName . name
190
197
) {
191
198
breakingChanges . push ( {
192
199
type : BreakingChangeType . ARG_CHANGED_KIND ,
You can’t perform that action at this time.
0 commit comments