Support type extensions with unreachable types policy rule#7978
Conversation
There was a problem hiding this comment.
Code Review
The changes update the no-unreachable-types rule within the @graphql-eslint/eslint-plugin patch to include extensionASTNodes when traversing reachable types. A test case was added to validate this fix, though the provided GraphQL SDL in the test is syntactically invalid and requires a proper base type definition as suggested.
| source: `type Query extend type Query { foo: Foo } type Foo { id: ID! }`, | ||
| schema: `type Query extend type Query { foo: Foo } type Foo { id: ID! }`, |
There was a problem hiding this comment.
The GraphQL SDL provided in the test case is syntactically invalid. A base type definition like type Query requires a field set (e.g., { id: ID }), and it should be separated from the extension. To properly test that Foo is reachable via an extension, the SDL should define a valid base type and then extend it.
| source: `type Query extend type Query { foo: Foo } type Foo { id: ID! }`, | |
| schema: `type Query extend type Query { foo: Foo } type Foo { id: ID! }`, | |
| source: "type Query { id: ID } extend type Query { foo: Foo } type Foo { id: ID! }", | |
| schema: "type Query { id: ID } extend type Query { foo: Foo } type Foo { id: ID! }", |
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
n1ru4l
left a comment
There was a problem hiding this comment.
add a changeset before merging 👍
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-hive/laboratory |
0.1.4-alpha-20260415145334-31a155f9dda3b3b8738906c01d5400c688ea6c61 |
npm ↗︎ unpkg ↗︎ |
@graphql-hive/render-laboratory |
0.1.4-alpha-20260415145334-31a155f9dda3b3b8738906c01d5400c688ea6c61 |
npm ↗︎ unpkg ↗︎ |
hive |
11.0.3-alpha-20260415145334-31a155f9dda3b3b8738906c01d5400c688ea6c61 |
npm ↗︎ unpkg ↗︎ |
Background
The policy schema is a merged version of the subgraph schemas. It contains directives and type extensions as it is not yet converted to an API schema... (Confusing, right?)
Since this can contain type extensions, and linting runs against it, the linting rules must handle type extensions
Internal ref: https://linear.app/the-guild/issue/GW-594/investigate-unreachable-types-policy-issue-in-hive
Description
This change adds support for type extensions with the unreachable types rule by ensuring it visits these extension nodes.
Checklist