Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

CamelCased Types cannot use sub-query filters because generated cypher code has inconsistent variable naming #309

Closed
henrikleion opened this issue Sep 13, 2019 · 1 comment

Comments

@henrikleion
Copy link

Hi

When filtering on a related node where the type is CamelCased, the generated Cypher code contains a variable which on the top-level looks like this: camelCase, and in the sub-query looks like camelcase. Since the variables in the top-level and sub-level queries don't match, the query gets zero hits.

Here's my example:

Simple filtering works fine, I get a number of Parts:
{Part(filter: { MFGpartNumber_contains: "220" }) { MFGpartNumber } }

But using the same filter as a subquery yields 0 results:
{CustomerRfq(filter: { parts: { Part: { MFGpartNumber_contains: "220" } } }) { parts { Part { MFGpartNumber } } } }

Now, if we look at the generated cypher code from the failed query, it looks like this:
MATCH (customerRfq:CustomerRfq) WHERE (EXISTS((customerRfq)-[:RFQ_CONTAINS]->(:Part)) AND ALL(customerrfq_filter_part IN [(customerrfq)-[_customerrfq_filter_part:RFQ_CONTAINS]->(:Part) | _customerrfq_filter_part] WHERE (ALL(part IN [(customerrfq)-[customerrfq_filter_part]->(_part:Part) | _part] WHERE (part.MFGpartNumber CONTAINS "220"))))) RETURN customerRfq {parts: [(customerRfq)-[customerRfq_parts_relation:RFQ_CONTAINS]->(:Part) | customerRfq_parts_relation {Part: head([(:CustomerRfq)-[customerRfq_parts_relation]->(customerRfq_parts_Part:Part) | customerRfq_parts_Part { .MFGpartNumber }]) }] } AS customerRfq

Note the variable defined at the very beginning named "customerRfq".
Inside the generated cypher code there are two subqueries which refer back to this variable but they have been lower-cased:

...part IN [(customerrfq)...
and
...customerrfq_filter_part IN [(customerrfq)...

If I take the whole generated query, paste it into Neo4j desktop and correct the two variable references to "customerRfq" which is defined in the outer top-level query, I get the expected response.

If I change the camel-cased Type to Customerrfq in the GraphQL schema and reload the database, the generated query works as intended.

My api app is based on the GRANDstack starter and has:
"dependencies": {
"apollo-boost": "^0.3.1",
"apollo-cache-inmemory": "^1.6.3",
"apollo-client": "^2.6.4",
"apollo-link-http": "^1.5.15",
"apollo-server": "^2.8.2",
"dotenv": "^7.0.0",
"graphql-tag": "^2.10.1",
"neo4j-driver": "^1.7.5",
"neo4j-graphql-js": "^2.7.1",
"node-fetch": "^2.6.0",
"typeface-roboto": "0.0.54"
}

@johnymontana
Copy link
Contributor

Fixed by #325 please reopen if you're still seeing this problem

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

No branches or pull requests

2 participants