@graphql-eslint/eslint-插件错误

Roy*_*itz 5 typescript eslint graphql graphql-js nestjs

我们正在使用 NestJS-typescript 开发微服务,每个服务都公开一个 GraphQL 模式。为了公开单个图,我们也在 NestJS 中使用联合服务。

我试图与“@graphql-eslint/eslint-plugin”集成,并引发了一些奇怪的异常:

未知指令“@key”

这些错误已在 GitHub 问题后解决:https ://github.com/cjoudrey/graphql-schema-linter/issues/210

我根据 Apollo 文档创建了一个具有类型规范的新文件:https://www.apollographql.com/docs/federation/federation-spec/#federation-schema-specation

解决这个问题后,我又收到了一些错误,我不知道它们的含义以及如何解决它们:

解析错误:无法扩展类型“Query”,因为它未定义。您指的是“用户”吗?

无法扩展类型“Mutation”,因为它未定义。

未知类型“查询”。您指的是“用户”吗?

未知类型“Mutation”.eslint

这是我的架构:

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
}
Run Code Online (Sandbox Code Playgroud)

有谁知道为什么我会收到这些错误?

Jos*_* D. 0

正如错误所述,“查询”和“突变”未定义。

在扩展它之前必须首先定义它,如下所示:

type Query {
  _empty: String
}

type Mutation {
  _empty: String
}
Run Code Online (Sandbox Code Playgroud)