eslint-plugin-graphql icon indicating copy to clipboard operation
eslint-plugin-graphql copied to clipboard

Query with field that is missing subfields selection causes rule crash

Open CraigCav opened this issue 7 years ago • 1 comments
trafficstars

ESLint crashes when there's a query with an Object Type field without a selection.

Schema:

type MyObjectType {
  id: ID!
  someField: String
}
type Query {
  fieldName: MyObjectType
}

Query:

{
  fieldName
}

Intended Outcome

Ideally:

[eslint] Field "fieldName" must have a selection since type "MyObjectType" is a GraphQL Object Type.

Actual Outcome

Cannot read property 'selections' of undefined
TypeError: Cannot read property 'selections' of undefined
    at getFieldWasRequestedOnNode (/[...]/node_modules/eslint-plugin-graphql/lib/rules.js:26:28)
    at /[...]/node_modules/eslint-plugin-graphql/lib/rules.js:60:35
    at Array.forEach (<anonymous>)
[...]

Version of eslint-plugin-graphql used: 2.1.1.

Issue Labels

  • [x] has-reproduction
  • [ ] feature
  • [ ] docs
  • [ ] blocking
  • [ ] good first issue

CraigCav avatar May 24 '18 13:05 CraigCav

Hey! Any updates on this issue or with the referenced PR?

mlnor27 avatar Mar 19 '21 13:03 mlnor27