Skip to content

Fragments are not validated against @graphql-eslint/require-id-when-available #1117

@benatshippabo

Description

@benatshippabo

Issue workflow progress

Progress of the issue based on the Contributor Workflow

  • 1. The issue provides a reproduction available on GitHub, Stackblitz or CodeSandbox

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

Fragments are not validated against @graphql-eslint/require-id-when-available rule.

Schema

type Query {
  user(id: String!): UserResult
}

union UserResult = Account | Error

type Account {
  id: ID!
  name: String!
  phone: String
}

type Error {
  message: String!
}

Query

query UserById($id: String!) {
  user(id: $id) {
    ... on Account {
      # inline fragment: we expect an error here about a missing `id` field
      ...UserFields
    }

    ... on Error {
      message
    }
  }
}

fragment UserFields on Account {
  # fragment: we expect an error here about a missing `id` field
  name
  phone
}

To Reproduce
Steps to reproduce the behavior:

https://github.com/benatshippabo/graphql-eslint-bug

Expected behavior

We expect eslint to error on the inline Account fragment and the Account fragment.

Environment:

  • OS: MacOS 12.4
  • @graphql-eslint/eslint-plugin: ^3.10.6
  • Node.js: v16.16.0

Additional context

Metadata

Metadata

Assignees

Labels

kind/bugBug :-(stage/6-releasedThe issue has been solved on a released version of the library

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions