Skip to content

Commit 1708107

Browse files
committed
Correct test and lint stuff
1 parent 1d120d0 commit 1708107

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

src/execution/__tests__/variables-test.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { inspect } from '../../jsutils/inspect.js';
77

88
import { GraphQLError } from '../../error/GraphQLError.js';
99

10+
import { DirectiveLocation } from '../../language/directiveLocation.js';
1011
import { Kind } from '../../language/kinds.js';
1112
import { parse } from '../../language/parser.js';
1213

@@ -22,15 +23,15 @@ import {
2223
GraphQLObjectType,
2324
GraphQLScalarType,
2425
} from '../../type/definition.js';
26+
import {
27+
GraphQLDirective,
28+
GraphQLIncludeDirective,
29+
} from '../../type/directives.js';
2530
import { GraphQLBoolean, GraphQLString } from '../../type/scalars.js';
2631
import { GraphQLSchema } from '../../type/schema.js';
2732

2833
import { executeSync } from '../execute.js';
2934
import { getVariableValues } from '../values.js';
30-
import { GraphQLSkipDirective } from '../../type/directives.js';
31-
import { GraphQLIncludeDirective } from '../../type/directives.js';
32-
import { GraphQLDirective } from '../../type/directives.js';
33-
import { DirectiveLocation } from '../../language/directiveLocation.js';
3435

3536
const TestFaultyScalarGraphQLError = new GraphQLError(
3637
'FaultyScalarErrorMessage',
@@ -1506,8 +1507,21 @@ describe('Execute: Handles inputs', () => {
15061507
fieldWithNonNullableStringInput @skip(if: $value)
15071508
}
15081509
`);
1509-
expect(result).to.deep.equal({
1510-
data: {},
1510+
1511+
expectJSON(result).toDeepEqual({
1512+
data: null,
1513+
errors: [
1514+
{
1515+
locations: [
1516+
{
1517+
column: 53,
1518+
line: 6,
1519+
},
1520+
],
1521+
message:
1522+
'Argument "if" of non-null type "Boolean!" must not be null.',
1523+
},
1524+
],
15111525
});
15121526
});
15131527
});

src/execution/collectFields.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,12 @@ function collectFieldsImpl(
164164
for (const selection of selectionSet.selections) {
165165
switch (selection.kind) {
166166
case Kind.FIELD: {
167-
const vars = localVariableValues ?? variableValues;
168-
if (!shouldIncludeNode(vars, selection)) {
167+
if (
168+
!shouldIncludeNode(
169+
{ ...variableValues, ...localVariableValues },
170+
selection,
171+
)
172+
) {
169173
continue;
170174
}
171175
groupedFieldSet.add(getFieldEntryKey(selection), {
@@ -177,7 +181,10 @@ function collectFieldsImpl(
177181
}
178182
case Kind.INLINE_FRAGMENT: {
179183
if (
180-
!shouldIncludeNode(variableValues, selection) ||
184+
!shouldIncludeNode(
185+
{ ...variableValues, ...localVariableValues },
186+
selection,
187+
) ||
181188
!doesFragmentConditionMatch(schema, selection, runtimeType)
182189
) {
183190
continue;
@@ -216,15 +223,18 @@ function collectFieldsImpl(
216223

217224
const newDeferUsage = getDeferUsage(
218225
operation,
219-
variableValues,
226+
{ ...variableValues, ...localVariableValues },
220227
selection,
221228
deferUsage,
222229
);
223230

224231
if (
225232
!newDeferUsage &&
226233
(visitedFragmentNames.has(fragmentName) ||
227-
!shouldIncludeNode(variableValues, selection))
234+
!shouldIncludeNode(
235+
{ ...variableValues, ...localVariableValues },
236+
selection,
237+
))
228238
) {
229239
continue;
230240
}

0 commit comments

Comments
 (0)