是否可以通过graphql-tools告诉makeExecutableSchema忽略某些指令?
我想用graphql查询我的neo4j数据库。我还希望能够在graphql中指定子类型。有一个称为graphql-s2s的库,它向graphql添加了子类型。库neo4j-graphql-js使用自定义指令(@cyper和@relation)来构建增强模式。它从graphql-tools获取typeDefs或可执行文件。 qraphql-s2s让我从包含子类型的Schema中创建一个可执行的Schema。我的希望是,我应该很容易像装饰器模式那样将不同的模式输出相互传递。
不幸的是,这显然不是它的工作方式,因为我收到了很多解析器错误消息,这些消息实际上并不是描述性的。
不幸的是,我还没有找到任何Grandstack文档,该文档没有显示如何在具有关系和密码的可执行文件上使用增强模式()。
有没有办法做到这一点?
在我幼稚的方法下面:
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}`);
});