Skip to content

Commit a27c4b2

Browse files
committed
fix: check the actual GraphQLDirective instance in isSpecifiedDirective
1 parent e2457b3 commit a27c4b2

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/type/__tests__/predicate-test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,5 +700,13 @@ describe('Directive predicates', () => {
700700
it('returns false for custom directive', () => {
701701
expect(isSpecifiedDirective(Directive)).to.equal(false);
702702
});
703+
704+
it('returns false for the directives with the same name as specified directives', () => {
705+
const FakeSkipDirective = new GraphQLDirective({
706+
name: 'skip',
707+
locations: [DirectiveLocation.QUERY],
708+
});
709+
expect(isSpecifiedDirective(FakeSkipDirective)).to.equal(false);
710+
});
703711
});
704712
});

src/type/directives.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,5 @@ export const specifiedDirectives: ReadonlyArray<GraphQLDirective> =
233233
]);
234234

235235
export function isSpecifiedDirective(directive: GraphQLDirective): boolean {
236-
return specifiedDirectives.some(({ name }) => name === directive.name);
236+
return specifiedDirectives.some(specifiedDirective => specifiedDirective === directive);
237237
}

0 commit comments

Comments
 (0)