Skip to content

Commit 00af02d

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

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

src/execution/__tests__/variables-test.ts

Lines changed: 9 additions & 5 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',
@@ -1507,7 +1508,10 @@ describe('Execute: Handles inputs', () => {
15071508
}
15081509
`);
15091510
expect(result).to.deep.equal({
1510-
data: {},
1511+
data: [null],
1512+
errors: [
1513+
'Argument "if" of non-null type "Boolean!" must not be null.\n\nGraphQL request:6:53\n5 | fragment a($value: Boolean) on TestType {\n6 | fieldWithNonNullableStringInput @skip(if: $value)\n | ^\n7 | }',
1514+
],
15111515
});
15121516
});
15131517
});

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)