问题描述
我正在尝试使用远程 neo4j 数据库设置 GRAND STACK 项目,以下是非常基本的连接代码:
const { Neo4jGraphQL } = require("@neo4j/graphql");
const neo4j = require("neo4j-driver");
const { ApolloServer } = require("apollo-server");
const typeDefs = `
type Feature {
id: Int
name: String @cypher(statement: "MATCH (n:feature) RETURN n LIMIT 25")
}
type Symptom {
id: Int
name: String @cypher(statement: "MATCH (n:symptom) RETURN n LIMIT 25")
}
type Query {
features: [Feature],symptoms: [Symptom]
}
`;
const driver = neo4j.driver(
"bolt://serverip:7687",neo4j.auth.basic("neo4j","hello-hello-hello")
);
const neoSchema = new Neo4jGraphQL({ typeDefs,driver });
// const resolvers = {
// Query: {
// feature: () => feature,// },// };
const server = new ApolloServer({
schema: neoSchema.schema,context: ({ req }) => ({ req }),// resolvers
});
server.listen(4000).then(() => console.log("Online"));
我正在做以下查询:
query Query {
symptoms {
name
}
}
查询总是返回空值。任何帮助将不胜感激。谢谢。
解决方法
Neo4j GraphQL 会为您自动生成查询和变更。在您的 typeDefs
中删除手动查询:
type Query {
features: [Feature]
symptoms: [Symptom]
}