Skip to content

Commit

Permalink
Correct test and lint stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Aug 25, 2024
1 parent 1d120d0 commit 1708107
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 11 deletions.
26 changes: 20 additions & 6 deletions src/execution/__tests__/variables-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { inspect } from '../../jsutils/inspect.js';

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

import { DirectiveLocation } from '../../language/directiveLocation.js';
import { Kind } from '../../language/kinds.js';
import { parse } from '../../language/parser.js';

Expand All @@ -22,15 +23,15 @@ import {
GraphQLObjectType,
GraphQLScalarType,
} from '../../type/definition.js';
import {
GraphQLDirective,
GraphQLIncludeDirective,
} from '../../type/directives.js';
import { GraphQLBoolean, GraphQLString } from '../../type/scalars.js';
import { GraphQLSchema } from '../../type/schema.js';

import { executeSync } from '../execute.js';
import { getVariableValues } from '../values.js';
import { GraphQLSkipDirective } from '../../type/directives.js';
import { GraphQLIncludeDirective } from '../../type/directives.js';
import { GraphQLDirective } from '../../type/directives.js';
import { DirectiveLocation } from '../../language/directiveLocation.js';

const TestFaultyScalarGraphQLError = new GraphQLError(
'FaultyScalarErrorMessage',
Expand Down Expand Up @@ -1506,8 +1507,21 @@ describe('Execute: Handles inputs', () => {
fieldWithNonNullableStringInput @skip(if: $value)
}
`);
expect(result).to.deep.equal({
data: {},

expectJSON(result).toDeepEqual({
data: null,
errors: [
{
locations: [
{
column: 53,
line: 6,
},
],
message:
'Argument "if" of non-null type "Boolean!" must not be null.',
},
],
});
});
});
Expand Down
20 changes: 15 additions & 5 deletions src/execution/collectFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,12 @@ function collectFieldsImpl(
for (const selection of selectionSet.selections) {
switch (selection.kind) {
case Kind.FIELD: {
const vars = localVariableValues ?? variableValues;
if (!shouldIncludeNode(vars, selection)) {
if (
!shouldIncludeNode(
{ ...variableValues, ...localVariableValues },
selection,
)
) {
continue;
}
groupedFieldSet.add(getFieldEntryKey(selection), {
Expand All @@ -177,7 +181,10 @@ function collectFieldsImpl(
}
case Kind.INLINE_FRAGMENT: {
if (
!shouldIncludeNode(variableValues, selection) ||
!shouldIncludeNode(
{ ...variableValues, ...localVariableValues },
selection,
) ||
!doesFragmentConditionMatch(schema, selection, runtimeType)
) {
continue;
Expand Down Expand Up @@ -216,15 +223,18 @@ function collectFieldsImpl(

const newDeferUsage = getDeferUsage(
operation,
variableValues,
{ ...variableValues, ...localVariableValues },
selection,
deferUsage,
);

if (
!newDeferUsage &&
(visitedFragmentNames.has(fragmentName) ||
!shouldIncludeNode(variableValues, selection))
!shouldIncludeNode(
{ ...variableValues, ...localVariableValues },
selection,
))
) {
continue;
}
Expand Down

0 comments on commit 1708107

Please sign in to comment.