graphql - 从驱动程序推断出架构后,如何合并架构?
问题描述
我使用 inferSchema 直接从 neo4j 数据库生成 GraphQL 类型定义,如下所示:
const inferAugmentedSchema = driver => {
return inferSchema(driver).then(result => {
return makeAugmentedSchema({
typeDefs: result.typeDefs,
config: {
mutation: false
}
});
})
};
现在我需要将上面的模式与另一个模式合并,这样我就可以扩展一个类型,但是每次我尝试都会引发这个错误:
初始化 Neo4j 架构
这可能需要一些时间,具体取决于数据库 pathToProject\node_modules\graphql\validation\validate.js:124 的大小
throw new Error(errors.map(function (error) { ^ Error: Cannot extend type " Municipio”,因为它没有定义。
这是我尝试合并它的完整代码:
const driver = neo4j.driver(
process.env.URL,
neo4j.auth.basic(process.env.NEO4J_USER, process.env.NEO4J_PWD)
);
const inferAugmentedSchema = driver => {
return inferSchema(driver).then(result => {
return makeAugmentedSchema({
typeDefs: result.typeDefs,
config: {
mutation: false
}
});
})
};
const types = [
inferAugmentedSchema,
municipioExtended,
];
const mergedSchema = mergeSchemas({
schemas: [typeDefs, municipioExtended]
});
const server = new ApolloServer({
mergedSchema,
context: { driver }
});
server.listen().then(({url}) => {
console.log(`server ready at ${url}`)
});
解决方案
推荐阅读
- javascript - input.scrollLeft 在 Chome 和 Firefox 中的行为异常
- svg - 根据现有形状生成 SVG 路径
- javascript - 从抽搐获取 json API。当我不在线时得到 Uncaught TypeError。JSON 更改
- google-cloud-functions - 来自 Cloud Function 的 Amazon MWS API 503,来自 Local 的 200
- nginx - 使用 Istio 和 Envoy sidecar 保留客户端 IP,并使用 custon nginx 作为负载均衡器
- ios - Swift ios如何找出标签文本是否被截断
- excel - 升级到 Office365 ProPlus 后 Excel VBA 运行速度极慢
- asp.net-core - Azure AD 将访问令牌发送到 Web API
- java - 将位图从 Java 类返回到 Activity
- sql - BI Publisher 不显示日期信息