Skip to content

Commit

Permalink
remove unused code, TODO: double check whether we deleted crucial bra…
Browse files Browse the repository at this point in the history
…nches
  • Loading branch information
JoviDeCroock committed Feb 1, 2024
1 parent eb0d997 commit d5ad911
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
6 changes: 1 addition & 5 deletions src/execution/collectFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ export function collectFields(
visitedFragmentNames: new Set(),
};

collectFieldsImpl(
context,
operation.selectionSet,
groupedFieldSet,
);
collectFieldsImpl(context, operation.selectionSet, groupedFieldSet);
return groupedFieldSet;
}

Expand Down
29 changes: 2 additions & 27 deletions src/execution/values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function coerceVariableValues(
*/
export function getArgumentValues(
node: FieldNode | DirectiveNode,
argDefs: ReadonlyArray<GraphQLArgument> | undefined,
argDefs: ReadonlyArray<GraphQLArgument>,
variableValues: Maybe<ObjMap<unknown>>,
fragmentArgValues?: Maybe<ObjMap<unknown>>,
): { [argument: string]: unknown } {
Expand All @@ -169,7 +169,7 @@ export function getArgumentValues(
node.arguments?.map((arg) => [arg.name.value, arg]),
);

for (const argDef of argDefs ?? []) {
for (const argDef of argDefs) {
const name = argDef.name;
const argType = argDef.type;
const argumentNode = argNodeMap.get(name);
Expand Down Expand Up @@ -291,27 +291,11 @@ export function getArgumentValuesFromSpread(
Object.hasOwn(fragmentArgValues, variableName)
) {
hasValue = fragmentArgValues[variableName] != null;
if (!hasValue && varDef.defaultValue !== undefined) {
coercedValues[name] = valueFromASTUntyped(varDef.defaultValue);
continue;
}
} else if (
variableValues != null &&
Object.hasOwn(variableValues, variableName)
) {
hasValue = variableValues[variableName] != null;
} else if (varDef.defaultValue !== undefined) {
coercedValues[name] = valueFromASTUntyped(varDef.defaultValue);
continue;
} else if (isNonNullType(argType)) {
throw new GraphQLError(
`Argument "${name}" of required type "${inspect(argType)}" ` +
`was provided the variable "$${variableName}" which was not provided a runtime value.`,
{ nodes: valueNode },
);
} else {
coercedValues[name] = undefined;
hasValue = false;
}
}

Expand All @@ -332,15 +316,6 @@ export function getArgumentValuesFromSpread(
});
}

if (coercedValue === undefined) {
// Note: ValuesOfCorrectTypeRule validation should catch this before
// execution. This is a runtime check to ensure execution does not
// continue with an invalid argument value.
throw new GraphQLError(
`Argument "${name}" has invalid value ${print(valueNode)}.`,
{ nodes: valueNode },
);
}
coercedValues[name] = coercedValue;
}
return coercedValues;
Expand Down

0 comments on commit d5ad911

Please sign in to comment.