Filter issue when using the same Operator on the same Field twice
michael-forman opened this issue · comments
Hi,
I've an issue with a filter when I do an OR and use the same Operator and field name twice.
query {
person(filter: { AND: [ { name_starts_with: "Aaron" },
{ OR: [ { name_ends_with: "a" }, { name_ends_with: "s" } ] } ] }) {
name
uuid
}
}
the generated cypher only creates a parameter for one of the names_ends_with
DEBUG [2020-08-24 10:24:24,396] ...: Executing Cypher query [MATCH (person:Person) WHERE ((person.name STARTS WITH $filterPersonName_SW) AND (((person.name ENDS WITH $filterPersonName_EW) OR (person.name ENDS WITH $filterPersonName_EW))))
RETURN person { .name, .uuid } AS person]
DEBUG [2020-08-24 10:24:24,396] ...: With Cypher parameters [{filterPersonName_EW=s, filterPersonName_SW=Aaron}]
When I use the same graphql and schema with the js version:
20:23:22 api | 2020-08-24T10:23:22.515Z neo4j-graphql-js MATCH (`person`:`Person`) WHERE (ALL(_AND IN $filter.AND WHERE (_AND.name_starts_with IS NULL OR `person`.name STARTS WITH _AND.name_starts_with) AND (_AND.OR IS NULL OR ANY(_OR IN _AND.OR WHERE (_OR.name_ends_with IS NULL OR `person`.name ENDS WITH _OR.name_ends_with))))) RETURN `person` { .name , .uuid } AS `person`
20:23:22 api | 2020-08-24T10:23:22.516Z neo4j-graphql-js {
20:23:22 api | "offset": 0,
20:23:22 api | "first": -1,
20:23:22 api | "filter": {
20:23:22 api | "AND": [
20:23:22 api | {
20:23:22 api | "name_starts_with": "Aaron"
20:23:22 api | },
20:23:22 api | {
20:23:22 api | "OR": [
20:23:22 api | {
20:23:22 api | "name_ends_with": "a"
20:23:22 api | },
20:23:22 api | {
20:23:22 api | "name_ends_with": "s"
20:23:22 api | }
20:23:22 api | ]
20:23:22 api | }
20:23:22 api | ]
20:23:22 api | }
20:23:22 api | }
Cheers,
Michael
I noticed that if I parameterise the values in my query it works:
query {
person(filter: { AND:[ { name_starts_with: $sw }
{OR:[
{ name_ends_with: $ew1 },
{ name_ends_with: $ew2 } ]} ] } ) {
name
uuid
}
}
with variables
{"sw":"Aar",
"ew1":"a",
"ew2":"s"
}
gives me the expected results.