Skip to content

fix: require-selections requireAllFields false positives #2912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

tpict
Copy link

@tpict tpict commented May 8, 2025

Description

When using the require-selections rule with the requireAllFields option, a selection on a type that has any of the fieldNames is demanded to include all of the fieldNames, whether or not they exist on that type.

The issue lies in the checkFields function. It exits early if the type being inspected doesn't implement any of the fieldNames configured for the rule. Otherwise, it proceeds to report on all of the fieldNames configured for the rule, not just the ones that exist on the type.

Fixes #2911

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as
    expected)
  • This change requires a documentation update

How Has This Been Tested?

A unit test that fails without the update to the rule has been added.

Test Environment:

  • OS: macOS
  • @graphql-eslint/...: 4.4.0
  • NodeJS: 22.7.0

Checklist:

  • I have followed the
    CONTRIBUTING doc and the
    style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@tpict tpict changed the title Tpict/fix require fields fix: require-selections requireAllFields false positives May 8, 2025
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.

requireAllFields option of require-selections demands nonexistent fields
1 participant