@graphql-eslint/eslint-plugin errors

Viewed 542

We are developing micro-services in NestJS-typescript, Each of them exposes a GraphQL schema. In order to expose a single graph, we are using a federation service, also in NestJS.

I was trying to integrate with '@graphql-eslint/eslint-plugin' and some strange exceptions were thrown:

Unknown directive "@key"

Those errors were solved following a GitHub issue: https://github.com/cjoudrey/graphql-schema-linter/issues/210

I have created a new file with the type specifications according to the Apollo documentation: https://www.apollographql.com/docs/federation/federation-spec/#federation-schema-specification

After solving this issue, I am getting few more errors that I have no idea what they mean and how to solve them:

Parsing error: Cannot extend type "Query" because it is not defined. Did you mean "User"?

Cannot extend type "Mutation" because it is not defined.

Unknown type "Query". Did you mean "User"?

Unknown type "Mutation".eslint

This is my schema:

extend type Query {
  users: [User]
  user(email: EmailAddress!): User
}

extend type Mutation {
  createUser(userData: UserData!): User
}

type User @key(fields: "email") {
  email: String!
  name: String
}

input UserData {
  email: String!
  name: String
}

Does anyone have an idea why I am getting those errors?

1 Answers

As the error states, "Query" and "Mutation" are not defined.

It must first be defined before extending it, like so:

type Query {
  _empty: String
}

type Mutation {
  _empty: String
}
Related