Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-27-2019 01:42 PM
I have simple neo4j & graphql example. Here is my 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")
}
`;
I'm able to fetch all data except reportees, which is always blank. What am I missing here? Here is sample cypher create scripts I used for this example.
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)
Solved! Go to Solution.
11-27-2019 02:12 PM
Mostly it looks OK, but your nodes are labeled EMP while your Typedef is Employee, which doesn't match. I wouldn't expect that sample data to work with that typedef, because under the covers it will be looking for Employee nodes, and not EMP nodes as what is actually in the database.
Also, if you fix this labeling issue -- what cypher gets generated?
Also -- in your @relation
you should probably specify direction: "OUT" and not both. "Reports to" is a single-direction relationship, and the way you've got it will confuse things because a boss will report to their direct report as well.
11-27-2019 02:12 PM
Mostly it looks OK, but your nodes are labeled EMP while your Typedef is Employee, which doesn't match. I wouldn't expect that sample data to work with that typedef, because under the covers it will be looking for Employee nodes, and not EMP nodes as what is actually in the database.
Also, if you fix this labeling issue -- what cypher gets generated?
Also -- in your @relation
you should probably specify direction: "OUT" and not both. "Reports to" is a single-direction relationship, and the way you've got it will confuse things because a boss will report to their direct report as well.
11-28-2019 08:58 PM
Thank you @david.allen - you are correct
It works after changing to EMP and changing @relation to IN
All the sessions of the conference are now available online