Skip to content

Support type extensions with unreachable types policy rule#7978

Merged
jdolle merged 3 commits intomainfrom
no-unreachable-type-extensions
Apr 15, 2026
Merged

Support type extensions with unreachable types policy rule#7978
jdolle merged 3 commits intomainfrom
no-unreachable-type-extensions

Conversation

@jdolle
Copy link
Copy Markdown
Collaborator

@jdolle jdolle commented Apr 14, 2026

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

  • Testing

@jdolle jdolle requested a review from n1ru4l April 14, 2026 23:15
@jdolle jdolle self-assigned this Apr 14, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +217 to +218
source: `type Query extend type Query { foo: Foo } type Foo { id: ID! }`,
schema: `type Query extend type Query { foo: Foo } type Foo { id: ID! }`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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! }",

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: 31a155f9dda3b3b8738906c01d5400c688ea6c61

Copy link
Copy Markdown
Contributor

@n1ru4l n1ru4l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a changeset before merging 👍

@jdolle jdolle changed the title Support type extensions with unreachable types Support type extensions with unreachable types policy rule Apr 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

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 ↗︎

@jdolle jdolle merged commit 9c6989c into main Apr 15, 2026
24 checks passed
@jdolle jdolle deleted the no-unreachable-type-extensions branch April 15, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants