Skip to content

Commit 4b71558

Browse files
robrichardlilianammmatos
authored andcommitted
handle missing arguments property
1 parent 6780ca7 commit 4b71558

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/validation/rules/OverlappingFieldsCanBeMergedRule.js

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -654,27 +654,20 @@ function sameDirectiveArgument(
654654
directive2: DirectiveNode,
655655
argumentName: string,
656656
): boolean {
657-
if (!directive1.arguments) {
657+
/* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
658+
const args1 = directive1.arguments || [];
659+
const arg1 = find(args1, argument => argument.name.value === argumentName);
660+
if (!arg1) {
658661
return false;
659662
}
660-
const argument1 = find(
661-
directive1.arguments,
662-
argument => argument.name.value === argumentName,
663-
);
664-
if (!argument1) {
665-
return false;
666-
}
667-
if (!directive2.arguments) {
668-
return false;
669-
}
670-
const argument2 = find(
671-
directive2.arguments,
672-
argument => argument.name.value === argumentName,
673-
);
674-
if (!argument2) {
663+
664+
/* istanbul ignore next (See https://github.com/graphql/graphql-js/issues/2203) */
665+
const args2 = directive2.arguments || [];
666+
const arg2 = find(args2, argument => argument.name.value === argumentName);
667+
if (!arg2) {
675668
return false;
676669
}
677-
return sameValue(argument1.value, argument2.value);
670+
return sameValue(arg1.value, arg2.value);
678671
}
679672

680673
function getStreamDirective(

0 commit comments

Comments
 (0)