Skip to content

fix(graphql): apply root field and base rules together in naming-convention - #1256

Open
malept wants to merge 1 commit into
mainfrom
malept/dt-5640/fix/graphql-lint-naming-root-and-base-rules
Open

malept wants to merge 1 commit into
mainfrom
malept/dt-5640/fix/graphql-lint-naming-root-and-base-rules

Conversation

@malept

@malept malept commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

What this PR does / why we need it

naming-convention checked a field on a root type against its root-type selector alone. With the usual config, where FieldDefinition requires camelCase and FieldDefinition[parent.name.value=Query] forbids a get prefix, Query fields were never checked for casing. @graphql-eslint registers one listener per option key, so both rules apply to such a field.

Check a root field against its base rule, then its root rule, and report each violation.

Jira ID

DT-5640

Notes for your reviewers

I ran @graphql-eslint/eslint-plugin 3.13.1 and 3.20.1 to confirm both rules fire. That contradicts the existing test "Query field selector overrides the general FieldDefinition rule", so it is replaced with one that expects the base rule's violation.

Rejected review findings and intentional non-goals

These were raised in earlier reviews and deliberately left as they are. Do not raise them again unless the reasoning below no longer holds.

Rejected findings

  • None.

Intentional behavior

  • A field that fails both its base and its root rule is reported twice, even if the messages look alike. @graphql-eslint reports each rule separately and does not deduplicate.
  • Fields added by extend type Query are checked once, under the base type. gqlparser has already merged them into the base definition.
  • Only the base and root selectors exist in this port, so there is no selector specificity to model beyond "base first, then root".
  • The per-site slice allocation is not worth avoiding.

…ention

naming-convention resolved a root field such as a Query field to its
root selector alone, so an option like
"FieldDefinition[parent.name.value=Query]" with only forbiddenPrefixes
silently stopped the general "FieldDefinition" casing rule from running
on that type. @graphql-eslint registers one listener per option key, so
both rules apply to such a field, the less specific one first.

Check a root field against its base rule and then its root rule,
reporting each violation. Replace the test that expected the root rule
to override the base rule, which @graphql-eslint 3.13.1 and 3.20.1 do
not do.

Assisted-By: claude-sonnet 5.5 via opencode
@getoutreach-ci-1

Copy link
Copy Markdown
Contributor

Link to code coverage report (posted by coverbot 🤖)

@malept
malept marked this pull request as ready for review October 24, 2026 00:33
@malept
malept requested a review from a team as a code owner October 24, 2026 00:33
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.

1 participant