简体   繁体   中英

@graphql-eslint/eslint-plugin errors

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?

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM