Skip to content

Commit d8810c9

Browse files
committed
handle missing arguments property
1 parent 276710d commit d8810c9

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/validation/rules/OverlappingFieldsCanBeMerged.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -668,27 +668,20 @@ function sameDirectiveArgument(
668668
directive2: DirectiveNode,
669669
argumentName: string,
670670
): boolean {
671-
if (!directive1.arguments) {
671+
/* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
672+
const args1 = directive1.arguments || [];
673+
const arg1 = find(args1, argument => argument.name.value === argumentName);
674+
if (!arg1) {
672675
return false;
673676
}
674-
const argument1 = find(
675-
directive1.arguments,
676-
argument => argument.name.value === argumentName,
677-
);
678-
if (!argument1) {
679-
return false;
680-
}
681-
if (!directive2.arguments) {
682-
return false;
683-
}
684-
const argument2 = find(
685-
directive2.arguments,
686-
argument => argument.name.value === argumentName,
687-
);
688-
if (!argument2) {
677+
678+
/* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
679+
const args2 = directive2.arguments || [];
680+
const arg2 = find(args2, argument => argument.name.value === argumentName);
681+
if (!arg2) {
689682
return false;
690683
}
691-
return sameValue(argument1.value, argument2.value);
684+
return sameValue(arg1.value, arg2.value);
692685
}
693686

694687
function getStreamDirective(

0 commit comments

Comments
 (0)