Skip to content

Commit 428edc5

Browse files
committed
add stream directive overlapping fields tests
1 parent 14e109a commit 428edc5

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

src/validation/__tests__/OverlappingFieldsCanBeMerged-test.js

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,117 @@ describe('Validate: Overlapping fields can be merged', () => {
9898
`);
9999
});
100100

101+
it('Same stream directives supported', () => {
102+
// @stream is allowed on overlapping fields when they have the same label and
103+
// initial count.
104+
expectValid(`
105+
fragment differentDirectivesWithDifferentAliases on Dog {
106+
name @stream(label: "streamLabel", initial_count: 1)
107+
name @stream(label: "streamLabel", initial_count: 1)
108+
}
109+
`);
110+
});
111+
112+
it('different stream directive label', () => {
113+
// @stream is allowed on overlapping fields when they have the same label and
114+
// initial count.
115+
expectErrors(`
116+
fragment conflictingArgs on Dog {
117+
name @stream(label: "streamLabel", initial_count: 1)
118+
name @stream(label: "anotherLabel", initial_count: 1)
119+
}
120+
`).to.deep.equal([
121+
{
122+
message:
123+
'Fields "name" conflict because they have differing stream directives. Use different aliases on the fields to fetch both if this was intentional.',
124+
locations: [
125+
{ line: 3, column: 9 },
126+
{ line: 4, column: 9 },
127+
],
128+
},
129+
]);
130+
});
131+
132+
it('different stream directive initial_count', () => {
133+
// @stream is allowed on overlapping fields when they have the same label and
134+
// initial count.
135+
expectErrors(`
136+
fragment conflictingArgs on Dog {
137+
name @stream(label: "streamLabel", initial_count: 1)
138+
name @stream(label: "streamLabel", initial_count: 2)
139+
}
140+
`).to.deep.equal([
141+
{
142+
message:
143+
'Fields "name" conflict because they have differing stream directives. Use different aliases on the fields to fetch both if this was intentional.',
144+
locations: [
145+
{ line: 3, column: 9 },
146+
{ line: 4, column: 9 },
147+
],
148+
},
149+
]);
150+
});
151+
152+
it('different stream directive first missing args', () => {
153+
// @stream is allowed on overlapping fields when they have the same label and
154+
// initial count.
155+
expectErrors(`
156+
fragment conflictingArgs on Dog {
157+
name @stream
158+
name @stream(label: "streamLabel", initial_count: 1)
159+
}
160+
`).to.deep.equal([
161+
{
162+
message:
163+
'Fields "name" conflict because they have differing stream directives. Use different aliases on the fields to fetch both if this was intentional.',
164+
locations: [
165+
{ line: 3, column: 9 },
166+
{ line: 4, column: 9 },
167+
],
168+
},
169+
]);
170+
});
171+
172+
it('different stream directive second missing args', () => {
173+
// @stream is allowed on overlapping fields when they have the same label and
174+
// initial count.
175+
expectErrors(`
176+
fragment conflictingArgs on Dog {
177+
name @stream(label: "streamLabel", initial_count: 1)
178+
name @stream
179+
}
180+
`).to.deep.equal([
181+
{
182+
message:
183+
'Fields "name" conflict because they have differing stream directives. Use different aliases on the fields to fetch both if this was intentional.',
184+
locations: [
185+
{ line: 3, column: 9 },
186+
{ line: 4, column: 9 },
187+
],
188+
},
189+
]);
190+
});
191+
192+
it('different stream directive both missing args', () => {
193+
// @stream is allowed on overlapping fields when they have the same label and
194+
// initial count.
195+
expectErrors(`
196+
fragment conflictingArgs on Dog {
197+
name @stream
198+
name @stream
199+
}
200+
`).to.deep.equal([
201+
{
202+
message:
203+
'Fields "name" conflict because they have differing stream directives. Use different aliases on the fields to fetch both if this was intentional.',
204+
locations: [
205+
{ line: 3, column: 9 },
206+
{ line: 4, column: 9 },
207+
],
208+
},
209+
]);
210+
});
211+
101212
it('Same aliases with different field targets', () => {
102213
expectErrors(`
103214
fragment sameAliasesWithDifferentFieldTargets on Dog {

0 commit comments

Comments
 (0)