Skip to content

Commit fd465ae

Browse files
Add reproduction
1 parent f7611fa commit fd465ae

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

src/HotChocolate/Core/test/Validation.Tests/FieldSelectionMergingRuleTests.cs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,49 @@ fragment mergeIdenticalFieldsWithIdenticalValues on Dog {
9999
""");
100100
}
101101

102+
[Fact]
103+
public void MergeIdenticalFieldsWithIdenticalInputFieldValuesButDifferentOrdering()
104+
{
105+
ExpectValid(
106+
"""
107+
{
108+
findDog(complex: { name: "A", owner: "B", child: { owner: "D", name: "C" } }) {
109+
name
110+
}
111+
... mergeIdenticalFieldsWithIdenticalInputFieldValuesButDifferentOrdering
112+
}
113+
114+
fragment mergeIdenticalFieldsWithIdenticalInputFieldValuesButDifferentOrdering on Query {
115+
findDog(complex: { owner: "B", name: "A", child: { name: "C", owner: "D" } }) {
116+
barks
117+
}
118+
}
119+
""");
120+
}
121+
122+
[Fact]
123+
public void ConflictingInputFieldValues()
124+
{
125+
ExpectErrors(
126+
"""
127+
{
128+
findDog(complex: { name: "A", owner: "OTHER", child: { owner: "D", name: "C" } }) {
129+
name
130+
}
131+
... mergeIdenticalFieldsWithIdenticalInputFieldValuesButDifferentOrdering
132+
}
133+
134+
fragment mergeIdenticalFieldsWithIdenticalInputFieldValuesButDifferentOrdering on Query {
135+
findDog(complex: { owner: "B", name: "A", child: { name: "C", owner: "OTHER" } }) {
136+
barks
137+
}
138+
}
139+
""",
140+
t => Assert.Equal(
141+
"Encountered fields for the same object that cannot be merged.",
142+
t.Message));
143+
}
144+
102145
[Fact]
103146
public void ConflictingArgsOnValues()
104147
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[
2+
{
3+
"Message": "Encountered fields for the same object that cannot be merged.",
4+
"Code": null,
5+
"Path": null,
6+
"Locations": [
7+
{
8+
"Line": 2,
9+
"Column": 5
10+
},
11+
{
12+
"Line": 9,
13+
"Column": 5
14+
}
15+
],
16+
"Extensions": {
17+
"declaringTypeA": "Query",
18+
"declaringTypeB": "Query",
19+
"fieldA": "findDog",
20+
"fieldB": "findDog",
21+
"typeA": "Dog",
22+
"typeB": "Dog",
23+
"responseNameA": "findDog",
24+
"responseNameB": "findDog",
25+
"specifiedBy": "https://spec.graphql.org/October2021/#sec-Field-Selection-Merging"
26+
},
27+
"Exception": null
28+
}
29+
]

0 commit comments

Comments
 (0)