|
1 | 1 | from itertools import chain
|
2 |
| -from typing import Any, Collection, Dict, List, Optional, Tuple, Union, cast |
| 2 | +from typing import Any, Dict, List, Optional, Tuple, Union, cast |
3 | 3 |
|
4 | 4 | from ...error import GraphQLError
|
5 | 5 | from ...language import (
|
6 |
| - ArgumentNode, |
7 | 6 | FieldNode,
|
8 | 7 | FragmentDefinitionNode,
|
9 | 8 | FragmentSpreadNode,
|
10 | 9 | InlineFragmentNode,
|
| 10 | + ObjectFieldNode, |
| 11 | + ObjectValueNode, |
11 | 12 | SelectionSetNode,
|
12 |
| - ValueNode, |
13 | 13 | print_ast,
|
14 | 14 | )
|
15 | 15 | from ...type import (
|
@@ -551,7 +551,7 @@ def find_conflict(
|
551 | 551 | )
|
552 | 552 |
|
553 | 553 | # Two field calls must have the same arguments.
|
554 |
| - if not same_arguments(node1.arguments or [], node2.arguments or []): |
| 554 | + if stringify_arguments(node1) != stringify_arguments(node2): |
555 | 555 | return (response_name, "they have differing arguments"), [node1], [node2]
|
556 | 556 |
|
557 | 557 | if type1 and type2 and do_types_conflict(type1, type2):
|
@@ -582,24 +582,14 @@ def find_conflict(
|
582 | 582 | return None # no conflict
|
583 | 583 |
|
584 | 584 |
|
585 |
| -def same_arguments( |
586 |
| - arguments1: Collection[ArgumentNode], arguments2: Collection[ArgumentNode] |
587 |
| -) -> bool: |
588 |
| - if len(arguments1) != len(arguments2): |
589 |
| - return False |
590 |
| - for argument1 in arguments1: |
591 |
| - for argument2 in arguments2: |
592 |
| - if argument2.name.value == argument1.name.value: |
593 |
| - if stringify_value(argument1.value) != stringify_value(argument2.value): |
594 |
| - return False |
595 |
| - break |
596 |
| - else: |
597 |
| - return False |
598 |
| - return True |
599 |
| - |
600 |
| - |
601 |
| -def stringify_value(value: ValueNode) -> str: |
602 |
| - return print_ast(sort_value_node(value)) |
| 585 | +def stringify_arguments(field_node: FieldNode) -> str: |
| 586 | + input_object_with_args = ObjectValueNode( |
| 587 | + fields=tuple( |
| 588 | + ObjectFieldNode(name=arg_node.name, value=arg_node.value) |
| 589 | + for arg_node in field_node.arguments |
| 590 | + ) |
| 591 | + ) |
| 592 | + return print_ast(sort_value_node(input_object_with_args)) |
603 | 593 |
|
604 | 594 |
|
605 | 595 | def do_types_conflict(type1: GraphQLOutputType, type2: GraphQLOutputType) -> bool:
|
|
0 commit comments