Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationship properties not able to get #284

Open
Hashdhi opened this issue Dec 23, 2022 · 0 comments
Open

Relationship properties not able to get #284

Hashdhi opened this issue Dec 23, 2022 · 0 comments

Comments

@Hashdhi
Copy link

Hashdhi commented Dec 23, 2022

Schema

type Person {
  name: String
  age: Int
  livesIn : Location @relation(name:"LIVES_IN", direction: OUT)
  livedIn : [Location] @relation(name:"LIVED_IN", direction: OUT)
  born : Birth
  died : Death
}
interface Temporal {
  date: String
}
type Birth implements Temporal @relation(name:"BORN") {
  from: Person
  to: Location
  date: String
}
type Death implements Temporal @relation(name:"DIED",from:"who",to:"where") {
  who: Person
  where: Location
  date: String
}
interface Location {
  name: String
  founded: Person @relation(name:"FOUNDED", direction: IN)
  sort_Arg: String
}
type City implements Location {
  name: String
  founded: Person @relation(name:"FOUNDED", direction: IN)
  sort_Arg: String
  city_Arg: String
}
type Village implements Location {
  name: String
  founded: Person @relation(name:"FOUNDED", direction: IN)
  sort_Arg: String
  villageArg: String
}

there are two problems

  1. Unable to get only Relationship Property
query {
  persons{
      born{
          date
      }
  }
}

Cypher

MATCH (persons:Person)
CALL {
	WITH persons
	OPTIONAL MATCH (persons)-[personsBorn:BORN]->(personsBornTo:Location)
	RETURN personsBorn {
		.date
	} AS personsBorn LIMIT 1
}
RETURN persons {
	born: personsBorn
} AS persons

issue is there is no Location node . Location is interface .

  1. query interface
query {
  persons{
      born{
          date
          to {
              name
          }
      }
  }
}
MATCH (persons:Person)
CALL {
	WITH persons
	OPTIONAL MATCH (persons)-[personsBorn:BORN]->(personsBornTo:Location)
	RETURN personsBorn {
		.date,
		to: personsBornTo {
			.name,
			__typename: head([label IN labels(personsBornTo) WHERE label IN $personsBornToValidTypes])
		}
	} AS personsBorn LIMIT 1
}
RETURN persons {
	born: personsBorn
} AS persons

replaced param : personsBornToValidTypes=[City, Village]

Neo4j db version 4.4.3
lib version : 1.6.0

Test data :

CREATE
  (u1:Person {name: 'Hashi',age:10})

CREATE
  (u1:City {name: 'Bangalore'})
  
CREATE (a)-[r:BORN{date:'23-12-2013'}]->(b)
RETURN type(r), r.date

Two node [Person,City] one Relationship BORN

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant