Skip to content

Commit 6d958ea

Browse files
committed
fix error in no-unreachable-types rule on [email protected]
1 parent e01463b commit 6d958ea

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

.changeset/cool-tools-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-eslint/eslint-plugin': patch
3+
---
4+
5+
fix error in `no-unreachable-types` rule on [email protected]

packages/plugin/src/graphql-ast.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export function getReachableTypes(schema: GraphQLSchema): ReachableTypes {
2727
for (const { astNode } of [...objects, ...interfaces]) {
2828
visit(astNode, visitor);
2929
}
30-
} else {
30+
} else if (type.astNode) {
31+
// astNode can be undefined for ID, String, Boolean
3132
visit(type.astNode, visitor);
3233
}
3334
};
@@ -48,7 +49,8 @@ export function getReachableTypes(schema: GraphQLSchema): ReachableTypes {
4849
schema.getMutationType(),
4950
schema.getSubscriptionType(),
5051
]) {
51-
if (type) {
52+
// if schema don't have Query type, schema.astNode will be undefined
53+
if (type?.astNode) {
5254
visit(type.astNode, visitor);
5355
}
5456
}

0 commit comments

Comments
 (0)