【问题标题】:Neo4j with graphql: unable to fetch self reference typeNeo4j with graphql:无法获取自引用类型
【发布时间】:2020-03-23 12:31:15
【问题描述】:

我有简单的 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)

【问题讨论】:

    标签: neo4j graphql neo4j-graphql-js


    【解决方案1】:

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

    "MATCH (a:EMP)&lt;-[r:REPORTS_TO]-(b:EMP) RETURN a, r, b"

    【讨论】:

      猜你喜欢
      • 2020-03-21
      • 2019-11-29
      • 2020-11-10
      • 1970-01-01
      • 1970-01-01
      • 2019-08-07
      • 2019-07-19
      • 2021-03-06
      • 1970-01-01
      相关资源
      最近更新 更多