Skip to content

Conversation

@ardatan
Copy link
Owner

@ardatan ardatan commented Nov 12, 2025

Reverts #7679 which can cause unexpected breaking
changes so as before the schema extension node will always be converted to a schema definition node

@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2025

🦋 Changeset detected

Latest commit: 9cd34f3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 26 packages
Name Type
@graphql-tools/utils Patch
@graphql-tools/executor Patch
@graphql-tools/graphql-tag-pluck Patch
@graphql-tools/import Patch
@graphql-tools/links Patch
@graphql-tools/load Patch
@graphql-tools/merge Patch
@graphql-tools/mock Patch
@graphql-tools/node-require Patch
@graphql-tools/relay-operation-optimizer Patch
@graphql-tools/resolvers-composition Patch
@graphql-tools/schema Patch
@graphql-tools/apollo-engine-loader Patch
@graphql-tools/code-file-loader Patch
@graphql-tools/git-loader Patch
@graphql-tools/github-loader Patch
@graphql-tools/graphql-file-loader Patch
@graphql-tools/json-file-loader Patch
@graphql-tools/module-loader Patch
@graphql-tools/url-loader Patch
@graphql-tools/executor-apollo-link Patch
@graphql-tools/executor-envelop Patch
@graphql-tools/executor-legacy-ws Patch
@graphql-tools/executor-urql-exchange Patch
@graphql-tools/executor-yoga Patch
graphql-tools Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed schema definition node handling in schema printing to ensure consistent behavior.

Walkthrough

Updated schema AST kind selection to treat empty operationTypes arrays as schema definitions by changing the check from operationTypes.length to operationTypes != null. Also removed an unused stripIgnoredCharacters import and its associated test case.

Changes

Cohort / File(s) Summary
Schema kind selection logic
packages/utils/src/print-schema-with-directives.ts
Changed condition in astFromSchema from checking operationTypes.length to operationTypes != null, so an empty operationTypes array now yields a SCHEMA_DEFINITION instead of a SCHEMA_EXTENSION.
Test suite cleanup
packages/utils/tests/print-schema-with-directives.spec.ts
Removed the unused stripIgnoredCharacters import and deleted the test that compared a federation-style subgraph SDL, simplifying the test suite.
Changeset
.changeset/tricky-yaks-unite.md
Added a patch changeset entry documenting the reversion and reasoning to ensure schema extension nodes convert to schema definition nodes.

Sequence Diagram(s)

(omitted — changes are a small conditional logic update and a test removal; no new control flow warranting a sequence diagram)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Check astFromSchema conditional change and verify cases: null, undefined, empty array, non-empty array.
  • Run existing schema-related tests and confirm no regressions from the removed federation test.
  • Review changeset message for accuracy.

Possibly related PRs

Suggested reviewers

  • Aenimus

Poem

🐰
An empty list once turned extension by chance,
Now a null-check nudged it into definition's dance.
One test hopped away, tidy and small,
The schema stands clearer — spring in its call. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically identifies that this PR reverts a previous fix, directly corresponding to the changeset modifications.
Description check ✅ Passed The description is related to the changeset, explaining the reason for the revert and its impact on schema extension/definition node behavior.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch revert-7679-support-federation-style-subgraphs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 631cee3 and 4bbb9d6.

📒 Files selected for processing (2)
  • packages/utils/src/print-schema-with-directives.ts (1 hunks)
  • packages/utils/tests/print-schema-with-directives.spec.ts (0 hunks)
💤 Files with no reviewable changes (1)
  • packages/utils/tests/print-schema-with-directives.spec.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Unit Test on Node 18 (windows-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15
  • GitHub Check: Unit Test on Node 22 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 24 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Full Check on GraphQL v16
  • GitHub Check: deployment


const schemaNode: SchemaDefinitionNode | SchemaExtensionNode = {
kind: operationTypes.length ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
kind: operationTypes != null ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Condition always evaluates to true, making SCHEMA_EXTENSION unreachable.

The check operationTypes != null will always be true because operationTypes is defined on line 173 as an array (the result of filter(isSome)). Arrays are never null—they can only be empty. This means the code will always produce Kind.SCHEMA_DEFINITION, and the SCHEMA_EXTENSION branch is unreachable.

Apply this diff to fix the condition:

-    kind: operationTypes != null ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
+    kind: operationTypes.length > 0 ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
kind: operationTypes != null ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
kind: operationTypes.length > 0 ? Kind.SCHEMA_DEFINITION : Kind.SCHEMA_EXTENSION,
🤖 Prompt for AI Agents
In packages/utils/src/print-schema-with-directives.ts around line 182, the
ternary uses `operationTypes != null` which is always true because
`operationTypes` is an array; change the condition to check the array length
(e.g., `operationTypes.length > 0`) so that Kind.SCHEMA_DEFINITION is chosen
only when there are operation types and Kind.SCHEMA_EXTENSION is used when the
array is empty.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
.changeset/tricky-yaks-unite.md (1)

5-5: Wrap the bare URL to satisfy markdown linting.

The URL on line 5 is flagged by the markdown linter (MD034) as a bare URL and should be wrapped in angle brackets or converted to a proper markdown link.

Apply this diff to wrap the URL:

-Revert https://github.com/ardatan/graphql-tools/pull/7683 which can cause unexpected breaking
+Revert <https://github.com/ardatan/graphql-tools/pull/7683> which can cause unexpected breaking
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4bbb9d6 and 9cd34f3.

📒 Files selected for processing (1)
  • .changeset/tricky-yaks-unite.md (1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
.changeset/tricky-yaks-unite.md

5-5: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: deployment
  • GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v15
  • GitHub Check: Unit Test on Node 18 (windows-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 18 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 24 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Node 22 (ubuntu-latest) and GraphQL v16
  • GitHub Check: Unit Test on Bun
  • GitHub Check: Full Check on GraphQL v16
  • GitHub Check: alpha / snapshot

@github-actions
Copy link
Contributor

💻 Website Preview

The latest changes are available as preview in: https://pr-7683.graphql-tools.pages.dev

@ardatan ardatan merged commit 2fe123a into master Nov 12, 2025
15 checks passed
@ardatan ardatan deleted the revert-7679-support-federation-style-subgraphs branch November 12, 2025 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants