我有一个简单的neo4j&graphql示例。这是我的typeDefs:
const typeDefs = `
type Employee {
eid: ID!
name: String!
title: String!
email: String
reportees: [Employee] @relation(name: "REPORTS_TO", direction: "BOTH")
}
type Query {
getAllEmployees: [Employee] @cypher(statement: "MATCH (a:EMP)<-[:REPORTS_TO]-(b:EMP) RETURN a, b")
getEmployee(name: String): [Employee] @cypher(statement: "MATCH (e:EMP) WHERE e.name contains $name RETURN e")
}
`;
我能够获取除报告人之外的所有数据,该报告始终为空。我在这里想念什么?这是我在此示例中使用的示例密码创建脚本。
CREATE (gma:EMP {eid:"1", name: “George Hill”, title:”President", email:”g.hill@test.com"})
CREATE (aba:EMP {eid:"2", name: “Anna Syntel”, title:”Manager”, email:”Anna.s@test.com"})
CREATE (noa:EMP {eid:"3", name: “Nagz Hello”, title:”Developer”, email:”n.hello@test.com"})
CREATE
(aba)-[aa:REPORTS_TO]->(gma),
(noa)-[bb:REPORTS_TO]->(aba)
答案 0 :(得分:0)
您的查询仅返回两个EMP节点,而不返回关系。尝试查询
"MATCH (a:EMP)<-[r:REPORTS_TO]-(b:EMP) RETURN a, r, b"