@@ -588,12 +588,8 @@ function findConflict(
588
588
] ;
589
589
}
590
590
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
591
// Two field calls must have the same arguments.
596
- if ( ! sameArguments ( args1 , args2 ) ) {
592
+ if ( stringifyArguments ( node1 ) !== stringifyArguments ( node2 ) ) {
597
593
return [
598
594
[ responseName , 'they have differing arguments' ] ,
599
595
[ node1 ] ,
@@ -639,26 +635,19 @@ function findConflict(
639
635
}
640
636
}
641
637
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 ) ) ;
638
+ function stringifyArguments ( fieldNode : FieldNode ) : string {
639
+ // FIXME https://github.com/graphql/graphql-js/issues/2203
640
+ const args = /* c8 ignore next */ fieldNode . arguments ?? [ ] ;
641
+
642
+ const inputObjectWithArgs = {
643
+ kind : Kind . OBJECT ,
644
+ fields : args . map ( ( argNode ) => ( {
645
+ kind : Kind . OBJECT_FIELD ,
646
+ name : argNode . name ,
647
+ value : argNode . value ,
648
+ } ) ) ,
649
+ } ;
650
+ return print ( sortValueNode ( inputObjectWithArgs ) ) ;
662
651
}
663
652
664
653
// Two types conflict if both types could not apply to a value simultaneously.
0 commit comments