错误:未知指令";关系;。有一大堆neo4j

错误:未知指令";关系;。有一大堆neo4j,neo4j,graphql,grandstack,Neo4j,Graphql,Grandstack,我正在尝试neo4j的grand stack starter,在完成所有graphql模式部分后,API模块出现以下错误。它抱怨指令“关系”和“密码”是未知的。 我重新安装了neo4j graphql js,但没有解决问题。 下面是错误消息 grand-stack-starter-api@0.0.1 start C:\Users\grand-stack-starter-master\api nodemon --exec babel-node src/index.js [nodemon] 1.1

我正在尝试neo4j的grand stack starter,在完成所有graphql模式部分后,API模块出现以下错误。它抱怨指令“关系”和“密码”是未知的。 我重新安装了neo4j graphql js,但没有解决问题。 下面是错误消息

grand-stack-starter-api@0.0.1 start C:\Users\grand-stack-starter-master\api
nodemon --exec babel-node src/index.js

[nodemon] 1.18.9
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting babel-node src/index.js
C:\Users\grand-stack-starter-master\api\node_modules\graphql\validation\validate.js:89
throw new Error(errors.map(function (error) {
^

Error: Unknown directive "relation".

Unknown directive "relation".

Unknown directive "cypher".

Unknown directive "cypher".

Unknown directive "relation".

Unknown directive "relation".

Unknown directive "relation".

Unknown directive "relation".

Unknown directive "relation".

Unknown directive "cypher".
    at assertValidSDL (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql\validation\validate.js:89:11)
    at Object.buildASTSchema (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql\utilities\buildASTSchema.js:67:34)
    at Object.buildSchemaFromTypeDefinitions (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql-tools\src\generate\buildSchemaFromTypeDefinitions.ts:43:32)
    at makeExecutableSchema (C:\Users\N19683\grand-stack-starter-master\api\node_modules\graphql-tools\src\makeExecutableSchema.ts:52:16)
    at Object.<anonymous> (C:/Users/N19683/grand-stack-starter-master/api/src/index.js:18:16)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at loader (C:\Users\N19683\grand-stack-starter-master\api\node_modules\babel-register\lib\node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (C:\Users\N19683\grand-stack-starter-master\api\node_modules\babel-register\lib\node.js:154:7)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
**
index.js

import { typeDefs, resolvers } from "./graphql-schema";
import { ApolloServer, gql, makeExecutableSchema  } from "apollo-server";
import { v1 as neo4j } from "neo4j-driver";
import { augmentSchema } from "neo4j-graphql-js";
import dotenv from "dotenv";

// set environment variables from ../.env
dotenv.config();



const schema = makeExecutableSchema({
  typeDefs,
  resolvers
});

const augmentedSchema = augmentSchema(schema);

const driver = neo4j.driver(
  process.env.NEO4J_URI || "bolt://localhost:7689",
  neo4j.auth.basic(
    process.env.NEO4J_USER || "neo4j",
    process.env.NEO4J_PASSWORD || "letmein"
  )
);


const server = new ApolloServer({
  context: { driver },
  schema: augmentedSchema
});

server.listen(process.env.GRAPHQL_LISTEN_PORT, "0.0.0.0").then(({ url }) => {
  console.log(`GraphQL API ready at ${url}`);
});

任何人都可以帮助解决这个问题!提前感谢

如中所述

注意:仅当使用现有GraphQLSchema对象时才使用augmentSchema。在大多数情况下,您应该使用makeAugmentedSchema,它可以从类型定义构造GraphQLSchema对象

发生错误的原因是您试图使用
makeExecutableSchema
创建架构。
@relation
@cypher
指令仅由
neo4j-graphql
使用。由于它们实际上没有定义为模式的一部分,因此使用
makeExecutableSchema
构建模式将导致错误,就像使用任何其他未定义的指令一样

您应该只使用
makeAugmentedSchema

const schema = makeAugmentedSchema({
  typeDefs,
  resolvers,
})
const driver = /* ... */
const server = new ApolloServer({
  context: { driver },
  schema,
})

听上去,您使用了错误的函数来构建模式。请编辑您的问题以包含相关代码。谢谢@DanielRearden,我已经用我的代码更新了帖子!。提前谢谢!!非常感谢@Daniel Rearden!将makeExcutableSchema替换为MakeAgmentedSchema后,错误消失!!
const schema = makeAugmentedSchema({
  typeDefs,
  resolvers,
})
const driver = /* ... */
const server = new ApolloServer({
  context: { driver },
  schema,
})