Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
07-12-2020 05:30 AM
Hi, I am working with parts of the GRANDStack starter project (but changing it a bit for my own project). An issue is that I only get an empty array out of the following query and data:
GraphQL:
query { Company
{
name
person {
firstName
And the schema looks like this:
type Person {
id: ID!
name: String
firstName:String
lastName:String
company: Company @relation(name:"position", direction:IN)
}
type Company {
id: ID!
name: String
person: [Person] @relation(name:"position", direction:IN)
}
I am using CSV data from Linkedin so the results we are getting from the GraphQL query above looks like this:
{
"data": {
"Company": [
{
"name": "ABBA THE MUSEUM",
"person": []
},
{
"name": "ZAPLIFY",
"person": []
},
{
"name": "EVERYTIME FITNESS",
"person": []
}
07-12-2020 06:01 AM
Have you verified that the person nodes have been created? and/or attached to the company nodes via a relationship?
07-14-2020 05:32 AM
Yes they are being created and attached via relationships. Know any other solution?
07-14-2020 05:43 AM
https://imgur.com/a/iHfuUrl Picture 1 (GraphQL query result)
https://imgur.com/a/7fI2cuJ Picture 2 (Code of our schema)
https://imgur.com/a/3b1tbEW Picture 3 (How it looks like in Neo4j desktop)
07-14-2020 06:04 AM
So as you see in GraphQL query we get Person as an empty (see picture 1)
query Test { Company
{
name
person {
firstName
}
}
}
07-14-2020 08:54 AM
I think you need to be using the relationship name i.e. position :
query {
Company {
name
position {
firstName
}
}
}
Give that a shot
07-14-2020 09:36 AM
@MuddyBootsCode is correct about the need to use position in the query.
Also make one of the IN relations an OUT since they’re supposed to complement each other. And perhaps try to constrain your nodes more, for example making [People] into [People!]!. I’d actually do the same with Company.
07-14-2020 10:03 AM
Very good advice. Make it maybe a employer and employee relationship going in the correct respective directions and it’ll probably be a bit easier.
All the sessions of the conference are now available online