-1

我有简单的 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")
        }
`;

我能够获取除reportees之外的所有数据,这些数据始终为空。我在这里想念什么?这是我用于此示例的示例密码创建脚本。

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)
4

1 回答 1

0

您的查询仅返回两个 EMP 节点,不返回关系。试试查询

"MATCH (a:EMP)<-[r:REPORTS_TO]-(b:EMP) RETURN a, r, b"

于 2019-12-02T21:42:11.707 回答