Skip to content

Commit 32997e6

Browse files
committed
polish(OverlappingFieldsCanMerge): add tests documenting existing behavior
Replicates graphql/graphql-js@cbecc6e
1 parent 840cbf9 commit 32997e6

1 file changed

Lines changed: 100 additions & 10 deletions

File tree

‎tests/validation/test_overlapping_fields_can_be_merged.py‎

Lines changed: 100 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,68 @@ def deep_conflict_with_multiple_issues():
411411
],
412412
)
413413

414+
def does_not_compare_subfields_of_incompatible_parent_calls():
415+
assert_errors(
416+
"""
417+
fragment incompatibleParents on Dog {
418+
parent: mother {
419+
value: name
420+
}
421+
parent: father {
422+
value: mother { name }
423+
}
424+
}
425+
""",
426+
[
427+
{
428+
"message": "Fields 'parent' conflict because"
429+
" 'mother' and 'father' are different fields."
430+
" Use different aliases on the fields"
431+
" to fetch both if this was intentional.",
432+
"locations": [(3, 15), (6, 15)],
433+
}
434+
],
435+
)
436+
437+
def still_compares_subfields_of_each_compatible_parent_call_group():
438+
assert_errors(
439+
"""
440+
fragment mixedParents on Dog {
441+
parent: mother {
442+
value: name
443+
}
444+
parent: mother {
445+
value: mother { name }
446+
}
447+
parent: father { name }
448+
}
449+
""",
450+
[
451+
{
452+
"message": "Fields 'parent' conflict because"
453+
" subfields 'value' conflict because"
454+
" 'name' and 'mother' are different fields."
455+
" Use different aliases on the fields"
456+
" to fetch both if this was intentional.",
457+
"locations": [(3, 15), (4, 17), (6, 15), (7, 17)],
458+
},
459+
{
460+
"message": "Fields 'parent' conflict because"
461+
" 'mother' and 'father' are different fields."
462+
" Use different aliases on the fields"
463+
" to fetch both if this was intentional.",
464+
"locations": [(3, 15), (9, 15)],
465+
},
466+
{
467+
"message": "Fields 'parent' conflict because"
468+
" 'mother' and 'father' are different fields."
469+
" Use different aliases on the fields"
470+
" to fetch both if this was intentional.",
471+
"locations": [(6, 15), (9, 15)],
472+
},
473+
],
474+
)
475+
414476
def very_deep_conflict():
415477
assert_errors(
416478
"""
@@ -523,10 +585,10 @@ def reports_deep_conflict_in_nested_fragments():
523585
"""
524586
{
525587
field {
526-
...F
588+
...I
527589
},
528590
field {
529-
...I
591+
...F
530592
}
531593
}
532594
fragment F on T {
@@ -547,19 +609,19 @@ def reports_deep_conflict_in_nested_fragments():
547609
[
548610
{
549611
"message": "Fields 'field' conflict"
550-
" because subfields 'x' conflict"
551-
" because 'a' and 'b' are different fields"
552-
" and subfields 'y' conflict"
553-
" because 'c' and 'd' are different fields."
612+
" because subfields 'y' conflict"
613+
" because 'd' and 'c' are different fields"
614+
" and subfields 'x' conflict"
615+
" because 'b' and 'a' are different fields."
554616
" Use different aliases on the fields"
555617
" to fetch both if this was intentional.",
556618
"locations": [
557619
(3, 15),
558-
(11, 15),
559-
(15, 15),
560-
(6, 15),
561-
(22, 15),
562620
(18, 15),
621+
(22, 15),
622+
(6, 15),
623+
(15, 15),
624+
(11, 15),
563625
],
564626
"path": None,
565627
}
@@ -621,6 +683,7 @@ def describe_return_types_must_be_unambiguous():
621683
scalar: String
622684
deepBox: StringBox
623685
unrelatedField: String
686+
listNode: [Node]
624687
listStringBox: [StringBox]
625688
stringBox: StringBox
626689
intBox: IntBox
@@ -630,6 +693,7 @@ def describe_return_types_must_be_unambiguous():
630693
scalar: Int
631694
deepBox: IntBox
632695
unrelatedField: String
696+
node: Node
633697
listStringBox: [StringBox]
634698
stringBox: StringBox
635699
intBox: IntBox
@@ -754,6 +818,32 @@ def disallows_differing_return_types_despite_no_overlap():
754818
schema,
755819
)
756820

821+
def does_not_compare_subfields_after_a_response_type_conflict():
822+
assert_errors(
823+
"""
824+
{
825+
someBox {
826+
... on StringBox {
827+
parent: listNode { value: name }
828+
}
829+
... on IntBox {
830+
parent: node { value: id }
831+
}
832+
}
833+
}
834+
""",
835+
[
836+
{
837+
"message": "Fields 'parent' conflict because"
838+
" they return conflicting types '[Node]' and 'Node'."
839+
" Use different aliases on the fields"
840+
" to fetch both if this was intentional.",
841+
"locations": [(5, 23), (8, 23)],
842+
}
843+
],
844+
schema,
845+
)
846+
757847
def reports_correctly_when_a_non_exclusive_follows_an_exclusive():
758848
assert_errors(
759849
"""

0 commit comments

Comments
 (0)