Description
Issue workflow progress
Progress of the issue based on the
Contributor Workflow
-
1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox
For example, you can start off by editing the
'basic' example on Stackblitz.Please make sure the graphql-eslint version under
package.json
matches yours. -
2. A failing test has been provided
-
3. A local solution has been provided
-
4. A pull request is pending review
Describe the bug
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.
To Reproduce Steps to reproduce the behavior:
I've included a unit test in my PR #2912 that reproduces the error: dfdda86
The issue occurs when requireAllFields
is set true
and a given type implements only some of the specified fieldNames
. e.g. given a schema
type User {
id: ID
name: String
posts: [Post]
}
type Post {
id: ID
title: String
content: String
author: [User!]!
}
a rule config
{ requireAllFields: true, fieldName: ['id', 'title', 'content'] }
and a document
{
user {
id
posts {
id
title
content
}
}
}
the rule will report that you must select the user.title
and user.content
fields, even though they don't exist.
Expected behavior
The lint rule should not fail selection sets based on the absence of fields that cannot be selected in that context.
Environment:
- OS: macOS
@graphql-eslint/eslint-plugin
: 4.4.0- Node.js: 22.7.0