Skip to content

Commit

Permalink
We don't require keying by spread + arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jan 27, 2024
1 parent e33eead commit dde52d7
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 36 deletions.
17 changes: 8 additions & 9 deletions src/execution/collectFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {
} from '../type/directives.js';
import type { GraphQLSchema } from '../type/schema.js';

import { keyForFragmentSpread } from '../utilities/keyForFragmentSpread.js';
import { substituteFragmentArguments } from '../utilities/substituteFragmentArguments.js';
import { typeFromAST } from '../utilities/typeFromAST.js';

Expand All @@ -44,7 +43,7 @@ interface CollectFieldsContext {
variableValues: { [variable: string]: unknown };
operation: OperationDefinitionNode;
runtimeType: GraphQLObjectType;
visitedFragmentKeys: Set<string>;
visitedFragmentNames: Set<string>;
}

/**
Expand All @@ -70,7 +69,7 @@ export function collectFields(
variableValues,
runtimeType,
operation,
visitedFragmentKeys: new Set(),
visitedFragmentNames: new Set(),
};

collectFieldsImpl(context, operation.selectionSet, groupedFieldSet);
Expand Down Expand Up @@ -102,7 +101,7 @@ export function collectSubfields(
variableValues,
runtimeType: returnType,
operation,
visitedFragmentKeys: new Set(),
visitedFragmentNames: new Set(),
};
const subGroupedFieldSet = new AccumulatorMap<string, FieldDetails>();

Expand Down Expand Up @@ -134,7 +133,7 @@ function collectFieldsImpl(
variableValues,
runtimeType,
operation,
visitedFragmentKeys,
visitedFragmentNames,
} = context;

for (const selection of selectionSet.selections) {
Expand Down Expand Up @@ -175,7 +174,7 @@ function collectFieldsImpl(
break;
}
case Kind.FRAGMENT_SPREAD: {
const fragmentKey = keyForFragmentSpread(selection);
const fragmentName = selection.name.value;

const newDeferUsage = getDeferUsage(
operation,
Expand All @@ -186,13 +185,13 @@ function collectFieldsImpl(

if (
!newDeferUsage &&
(visitedFragmentKeys.has(fragmentKey) ||
(visitedFragmentNames.has(fragmentName) ||
!shouldIncludeNode(variableValues, selection))
) {
continue;
}

const fragment = fragments[selection.name.value];
const fragment = fragments[fragmentName];
if (
fragment == null ||
!doesFragmentConditionMatch(schema, fragment, runtimeType)
Expand All @@ -201,7 +200,7 @@ function collectFieldsImpl(
}

if (!newDeferUsage) {
visitedFragmentKeys.add(fragmentKey);
visitedFragmentNames.add(fragmentName);
}

const fragmentSelectionSet = substituteFragmentArguments(
Expand Down
25 changes: 0 additions & 25 deletions src/utilities/keyForFragmentSpread.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/utilities/substituteFragmentArguments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import type {
import { Kind } from '../language/kinds.js';
import { visit } from '../language/visitor.js';

// TODO: follow up on https://github.com/graphql/graphql-js/pull/3835/files#r1101010604

/**
* Replaces all fragment argument values with non-fragment-scoped values.
*
Expand Down

0 comments on commit dde52d7

Please sign in to comment.