You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
In our schema we have defined rich relationship. When we are trying to filter on the end node of the relationship, it is throwing error.
GraphQL schema
type Person{
name: String
age: Int
rel_has_target_book: [Person_HAS_Target_Book]
}
type Book{
name: String
price: Int
}
type Person_HAS_Target_Book @relation(name: "HAS", from: "source", to: "target", direction: OUT) {
name: String
source: Person
target: Book
}
GraphQL request
query{
person{
name
rel_has_target_book(where:{target:{name:"Book 1"}}){
target{
name
}
}
}
}
Generated Cypher query
Here, "personRel_has_target_bookTarget" is the variable name for Book but in the where condition, "personRel_has_target_bookBook" is being used
MATCH (person:Person)
CALL {
WITH person
MATCH (person)-[personRel_has_target_book:HAS]->(personRel_has_target_bookTarget:Book)
WHERE personRel_has_target_bookBook.name = $personRel_has_target_bookBookName
RETURN collect(personRel_has_target_book {
target: personRel_has_target_bookTarget {
.name
}
}) AS personRel_has_target_book
}
RETURN person {
.name,
rel_has_target_book: personRel_has_target_book
} AS person
Variables: {personRel_has_target_bookBookName=Book 1}
Expected cypher query
MATCH (person:Person)
CALL {
WITH person
MATCH (person)-[personRel_has_target_book:HAS]->(personRel_has_target_bookBook:Book)
WHERE personRel_has_target_bookBook.name = $personRel_has_target_bookBookName
RETURN collect(personRel_has_target_book {
target: personRel_has_target_bookBook {
.name
}
}) AS personRel_has_target_book
}
RETURN person {
.name,
rel_has_target_book: personRel_has_target_book
} AS person
Variables: {personRel_has_target_bookBookName=Book 1}
Additional context
We looked into the codebase.
In the file "ProjectionBase.kt", if we modify the below line in the function "projectRichAndRegularRelationship", then the correct cypher query is being generated.
Before: node(label).named("$childVariable${relInfo.endField.capitalize()}") to relInfo.endField
After: node(label).named("$childVariable${label.capitalize()}") to label
The text was updated successfully, but these errors were encountered:
Andy2003
changed the title
Wrong variable name generating for end node in rich relationship
Wrong node name used for end node in rich relationship
Sep 12, 2023
Description
In our schema we have defined rich relationship. When we are trying to filter on the end node of the relationship, it is throwing error.
GraphQL schema
GraphQL request
Generated Cypher query
Here, "personRel_has_target_bookTarget" is the variable name for Book but in the where condition, "personRel_has_target_bookBook" is being used
Expected cypher query
Additional context
We looked into the codebase.
In the file "ProjectionBase.kt", if we modify the below line in the function "projectRichAndRegularRelationship", then the correct cypher query is being generated.
Before: node(label).named("$childVariable${relInfo.endField.capitalize()}") to relInfo.endField
After: node(label).named("$childVariable${label.capitalize()}") to label
The text was updated successfully, but these errors were encountered: