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

"required-fields" rule crash for InlineFragment

Open leethree opened this issue 8 years ago • 1 comments
trafficstars

Eslint crashes when there's a required field along with an inline fragment.

Eslint config:

"graphql/required-fields": ["error", {
      "requiredFields": ["id"],
      "schemaJsonFilepath": "./data/schema.json"
    }]

Schema:

interface Viewer {
  id: ID!
}
type UserViewer implements Viewer {
  id: ID!
  firstName: String
  lastName: String
}

Query:

{
  viewer {
    ... on UserViewer {
       firstName
    }
  }
}

Intended:

error  'id' field required on 'viewer'

Actual:

Cannot read property 'value' of undefined
TypeError: Cannot read property 'value' of undefined
    at /[...]/node_modules/eslint-plugin-graphql/lib/rules.js:44:26
    at Array.find (native)
    at /[...]/node_modules/eslint-plugin-graphql/lib/rules.js:42:66
[...]

leethree avatar Jun 29 '17 07:06 leethree

Any update on this issue? I'm seeing this as well.

cspeper avatar Feb 01 '18 21:02 cspeper