Skip to content

feat: sorted GraphQL documents - #12318

Merged
Netail merged 2 commits into
mainfrom
feat/useGraphqlSortedDefinitions
Oct 14, 2026
Merged

Netail merged 2 commits into
mainfrom
feat/useGraphqlSortedDefinitions

Conversation

@Netail

@Netail Netail commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Summary

Sort GraphQL documents, not sure about the rule name. Should we perhaps rename it to useGraphqlSortedDocuments?

Closes #9137 (last assist)

Partially generated by Claude 5.5 (Sonnet)

Test Plan

Unit tests

Docs

@github-actions github-actions Bot added A-Project Area: project A-Linter Area: linter A-Diagnostic Area: diagnostocis labels Oct 13, 2026
@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: biomejs/biome/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 91f97cac-3bfe-42e7-a305-40712a4770d1
📥 Commits

Reviewing files that changed from the base of the PR and between 38ce6d8 and 7636a3e.

⛔ Files ignored due to path filters: 10
  • crates/biome_diagnostics_categories/src/categories.rs is excluded by !**/categories.rs and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/invalid.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/invalidComments.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/invalidMixed.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/invalidNatural.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/invalidNoFix.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/invalidOperations.graphql.snap is excluded by !**/*.snap and included by **
  • crates/biome_graphql_analyze/tests/specs/source/useGraphqlSortedDefinitions/valid.graphql.snap is excluded by !**/*.snap and included by **
  • packages/@biomejs/backend-jsonrpc/src/workspace.ts is excluded by !**/backend-jsonrpc/src/workspace.ts and included by **
  • packages/@biomejs/biome/configuration_schema.json is excluded by !**/configuration_schema.json and included by **
📒 Files selected for processing: 1
  • crates/biome_graphql_analyze/src/assist/source/use_graphql_sorted_definitions.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The pull request adds the useGraphqlSortedDefinitions GraphQL assist. It reports unsorted document definitions and provides a fix that sorts eligible named definitions. The action is registered in the configuration, and its empty options type is declared and exported. GraphQL fixtures cover sorted and unsorted definitions, comments, mixed definition kinds and operations. A minor changeset is included.

Suggested reviewers: biome-cookie, ematipico

Priority: ⬇️ Low

Change: Feature

Merge Risk: ⚪ Minimal · up to 7636a

No merge-blocking issue was identified; the sorting action is ready for normal checks.

Pre-merge checks: Passed 4
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: sorting GraphQL documents.
Description check Passed The description directly covers the GraphQL sorting action, linked issue, naming consideration, and test plan.
Linked Issues check Passed Issue [#9137] leaves sorting GraphQL definitions as the active coding objective. The PR adds the useGraphqlSortedDefinitions assist action, registers its action name and options, sorts named definit…
Out of Scope Changes check Passed The changes stay within [#9137]. The action registration, options type, changeset, implementation, and test fixtures support the new GraphQL sorting assist. No unrelated product behaviour is evident.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@Netail
Netail marked this pull request as draft October 13, 2026 13:20
@codspeed

codspeed Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 19 untouched benchmarks
⏩ 400 skipped benchmarks1


Comparing feat/useGraphqlSortedDefinitions (7636a3e) with main (eca082b)

Open in CodSpeed

Footnotes

  1. 400 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment on lines +18 to +21
/// This action natural sorts the named definitions of a document by name: the `scalar`, `type`,
/// `interface`, `union`, `enum`, and `input` definitions, their `extend` counterparts,
/// the `directive` definitions, the `fragment` definitions, and the named `query`,
/// `mutation`, and `subscription` operations.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// This action natural sorts the named definitions of a document by name: the `scalar`, `type`,
/// `interface`, `union`, `enum`, and `input` definitions, their `extend` counterparts,
/// the `directive` definitions, the `fragment` definitions, and the named `query`,
/// `mutation`, and `subscription` operations.
/// This action natural sorts the named definitions of a document in the following order:
/// 1. The `scalar`, `type`, `interface`, `union`, `enum`, and `input` definitions, their `extend` counterparts.
/// 2. The `directive` definitions, the `fragment` definitions, and the named `query`.
/// 3. The `mutation`, and `subscription` operations.

What do you think? This this is a "order", a numeric list feels more intuitive.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Feels cleaner indeed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Oh wait, that would suggest they are grouped per numeric list entry and sorted within. They aren't, they can be mixed and sorted based on the name. It's just a list of what kind of document definitions are taken in the sorting

@Netail Netail Oct 13, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Grouping and sorting within could be a nice improvement later

@ematipico ematipico Oct 13, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's the possibility that I misunderstood the current docs though. I don't have GraphQL knowledge.

Comment thread crates/biome_graphql_analyze/src/assist/source/use_graphql_sorted_definitions.rs Outdated
Comment thread crates/biome_graphql_analyze/src/assist/source/use_graphql_sorted_definitions.rs Outdated
Comment thread crates/biome_graphql_analyze/src/assist/source/use_graphql_sorted_definitions.rs Outdated
@Netail Netail mentioned this pull request Oct 13, 2026
5 of 6 tasks
@Netail

Netail commented Oct 13, 2026

Copy link
Copy Markdown
Member Author

@biome-cookie review

@Netail Netail changed the title feat: alphabetize GraphQL documents feat: sorted GraphQL documents Oct 13, 2026

@biome-cookie biome-cookie left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Review Summary

Review complete. 1 finding was added inline.

Review Status

  • Scope: New GraphQL source assist action useGraphqlSortedDefinitions

  • Branch target: main

  • Changeset: .changeset/calm-seals-sort.md (minor)

  • Brief: Adds useGraphqlSortedDefinitions assist action to sort named GraphQL definitions

  • Validation: No verified suggested changes were published; findings may be based on static review.

  • Fetch: eca082b...38ce6d8

@changeset-bot

changeset-bot Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7636a3e

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

This PR includes changesets to release 16 packages
Name Type
@biomejs/biome Minor
@biomejs/cli-android-arm64 Minor
@biomejs/cli-android-x64 Minor
@biomejs/cli-darwin-arm64 Minor
@biomejs/cli-darwin-x64 Minor
@biomejs/cli-linux-arm64-musl Minor
@biomejs/cli-linux-arm64 Minor
@biomejs/cli-linux-x64-musl Minor
@biomejs/cli-linux-x64 Minor
@biomejs/cli-win32-arm64 Minor
@biomejs/cli-win32-x64 Minor
@biomejs/runtime Minor
@biomejs/wasm-bundler Minor
@biomejs/wasm-nodejs Minor
@biomejs/wasm-web Minor
@biomejs/backend-jsonrpc 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

@Netail
Netail force-pushed the feat/useGraphqlSortedDefinitions branch from f4cc12e to 7636a3e Compare October 14, 2026 08:54
@Netail
Netail marked this pull request as ready for review October 14, 2026 10:29
@Netail
Netail merged commit 774b5b5 into main Oct 14, 2026
35 checks passed
@Netail
Netail deleted the feat/useGraphqlSortedDefinitions branch October 14, 2026 10:48
@biomejs biomejs locked and limited conversation to collaborators Oct 14, 2026
@biomejs biomejs unlocked this conversation Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Diagnostic Area: diagnostocis A-Linter Area: linter A-Project Area: project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📎 Port GraphQL Eslint's alphabetize

4 participants