@@ -5,11 +5,10 @@ import type { ObjMap } from '../../jsutils/ObjMap';
5
5
import { GraphQLError } from '../../error/GraphQLError' ;
6
6
7
7
import type {
8
- ArgumentNode ,
9
8
FieldNode ,
10
9
FragmentDefinitionNode ,
10
+ ObjectValueNode ,
11
11
SelectionSetNode ,
12
- ValueNode ,
13
12
} from '../../language/ast' ;
14
13
import { Kind } from '../../language/kinds' ;
15
14
import { print } from '../../language/printer' ;
@@ -588,12 +587,8 @@ function findConflict(
588
587
] ;
589
588
}
590
589
591
- // FIXME https://github.com/graphql/graphql-js/issues/2203
592
- const args1 = /* c8 ignore next */ node1 . arguments ?? [ ] ;
593
- const args2 = /* c8 ignore next */ node2 . arguments ?? [ ] ;
594
-
595
590
// Two field calls must have the same arguments.
596
- if ( ! sameArguments ( args1 , args2 ) ) {
591
+ if ( stringifyArguments ( node1 ) !== stringifyArguments ( node2 ) ) {
597
592
return [
598
593
[ responseName , 'they have differing arguments' ] ,
599
594
[ node1 ] ,
@@ -639,26 +634,19 @@ function findConflict(
639
634
}
640
635
}
641
636
642
- function sameArguments (
643
- arguments1 : ReadonlyArray < ArgumentNode > ,
644
- arguments2 : ReadonlyArray < ArgumentNode > ,
645
- ) : boolean {
646
- if ( arguments1 . length !== arguments2 . length ) {
647
- return false ;
648
- }
649
- return arguments1 . every ( ( argument1 ) => {
650
- const argument2 = arguments2 . find (
651
- ( argument ) => argument . name . value === argument1 . name . value ,
652
- ) ;
653
- if ( ! argument2 ) {
654
- return false ;
655
- }
656
- return stringifyValue ( argument1 . value ) === stringifyValue ( argument2 . value ) ;
657
- } ) ;
658
- }
659
-
660
- function stringifyValue ( value : ValueNode ) : string {
661
- return print ( sortValueNode ( value ) ) ;
637
+ function stringifyArguments ( fieldNode : FieldNode ) : string {
638
+ // FIXME https://github.com/graphql/graphql-js/issues/2203
639
+ const args = /* c8 ignore next */ fieldNode . arguments ?? [ ] ;
640
+
641
+ const inputObjectWithArgs : ObjectValueNode = {
642
+ kind : Kind . OBJECT ,
643
+ fields : args . map ( ( argNode ) => ( {
644
+ kind : Kind . OBJECT_FIELD ,
645
+ name : argNode . name ,
646
+ value : argNode . value ,
647
+ } ) ) ,
648
+ } ;
649
+ return print ( sortValueNode ( inputObjectWithArgs ) ) ;
662
650
}
663
651
664
652
// Two types conflict if both types could not apply to a value simultaneously.
0 commit comments