-
Notifications
You must be signed in to change notification settings - Fork 93
Open
Description
My configuration:
'graphql/required-fields': [
'error',
{
env: 'apollo',
schemaJson: require('./schema.json'),
requiredFields: ['id'],
},
{
env: 'literal',
schemaJson: require('./schema.json'),
requiredFields: ['id'],
},
],
My query:
query Main {
nestedField {
...NestedField
}
}
fragment NestedField on SomeType {
id
someField
}
Expected result
No linter error.
Actual result
/path/MyQuery.graphql
2:3 error 'id' field required on 'nestedField' graphql/required-fields
Apparently the required-fields
rule doesn't account for fields included in a fragment.
Update
It seems like field selection merging is part of the GraphQL specification: https://graphql.github.io/graphql-spec/draft/#sec-Field-Selection-Merging
So this is not really a bug per se but more a feature request to be more exhaustive in checking for the inclusion of required fiels in fragments.
sashafklein, cjpete, moimael, jameswritescode, damondoucet and 18 more
Metadata
Metadata
Assignees
Labels
No labels