Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/Extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
DefinitionNode,
version as graphqlJSVersion,
TokenKind,
GraphQLError,
} from "graphql";
import { gte as semverGte } from "semver";
import {
Expand Down Expand Up @@ -536,7 +535,7 @@ class Extractor {
}

const locations = parser
.delimitedMany(TokenKind.PIPE, () => parser.parseDirectiveLocation())
.parseDirectiveLocations()
.map((location) => ({ ...location, loc: loc(tag) }));
return { name, repeatable, locations };
});
Expand Down Expand Up @@ -909,7 +908,11 @@ class Extractor {
parser.expectToken(TokenKind.EOF);
return result;
} catch (err) {
if (err instanceof GraphQLError) {
if (err instanceof Error && err.name === "GraphQLError") {
// Note: We use a name check instead of `instanceof GraphQLError`
// because in bundled environments (e.g. the playground), the
// GraphQLError class from the parser may be a different instance
// than the one we imported, causing `instanceof` to fail.
this.report(node, err.message);
} else {
throw err;
Expand Down
Loading