Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Neo4j 如何使makeExecutableSchema忽略指令?_Neo4j_Apollo_Subtyping_Graphql Tools_Grandstack - Fatal编程技术网

Neo4j 如何使makeExecutableSchema忽略指令?

Neo4j 如何使makeExecutableSchema忽略指令?,neo4j,apollo,subtyping,graphql-tools,grandstack,Neo4j,Apollo,Subtyping,Graphql Tools,Grandstack,有没有办法让graphql工具中的makeExecutableSchema忽略某些指令 我想用graphql查询我的neo4j数据库。我还希望能够在graphql中指定子类型。有一个名为graphql-s2s的库,它向graphql添加子类型。库neo4j graphql js使用自定义指令(@cyper和@relation)来构建扩展模式。它从graphql工具中获取typeDefs或executableSchema。qraphql-s2s允许我从包含子类型的模式中创建一个可执行模式。我的希望

有没有办法让graphql工具中的makeExecutableSchema忽略某些指令

我想用graphql查询我的neo4j数据库。我还希望能够在graphql中指定子类型。有一个名为graphql-s2s的库,它向graphql添加子类型。库neo4j graphql js使用自定义指令(@cyper和@relation)来构建扩展模式。它从graphql工具中获取typeDefs或executableSchema。qraphql-s2s允许我从包含子类型的模式中创建一个可执行模式。我的希望是,我应该能够轻松地将不同的模式输出像在装饰器模式中一样通过管道相互传递

不幸的是,这显然不是它的工作方式,因为我得到了很多解析器错误消息,这些消息并不是真正的描述性的

不幸的是,我还没有找到任何GrandTack文档,其中展示了如何在包含关系和密码的executableSchema上使用augmentSchema()

有没有办法做到这一点

下面是我天真的做法:

const { transpileSchema } = require('graphql-s2s').graphqls2s;
const { augmentSchema } = require('neo4j-graphql-js');
const { makeExecutableSchema} = require('graphql-tools');
const { ApolloServer} = require('apollo-server');

const driver = require('./neo4j-setup');

/** The @relation and @cypher directives don't make any sense here they are 
just for illustration of having directives that make sense to
'augmentSchema' and not to 'makeExecutableSchema' **/  

const schema = `
type Node {
    id: ID!
}

type Person inherits Node {
    firstname: String
    lastname: String @relation(name: "SOUNDS_LIKE", direction: "OUT") 
}

type Student inherits Person {
    nickname: String @cypher(
      statement: """ MATCH (n:Color)...some weird cypher query"""
    )
}

type Query {
  students: [Student]
}
`

const resolver = {
        Query: {
            students(root, args, context) {
                // Some dummy code
                return [{ id: 1, firstname: "Carry", lastname: "Connor", nickname: "Cannie" }]
            }
        }
    };

const executabledSchema = makeExecutableSchema({
  typeDefs: [transpileSchema(schema)],
  resolvers: resolver
})

const schema = augmentSchema(executabledSchema)

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

server.listen(3003, '0.0.0.0').then(({ url }) => {
  console.log(`GraphQL API ready at ${url}`);
});