neo4j-graphql / neo4j-graphql-java

Neo4j Labs Project: Pure JVM translation for GraphQL queries and mutations to Neo4j's Cypher
Apache License 2.0
105 stars 49 forks source link

Variables used multiple times breaks Cypher generation (duplicate statement parameters) #250

Open yarc opened 2 years ago

yarc commented 2 years ago

I'm currently running version 1.2.0 and i encountered this issue while upgrading to 1.4.0:

I have a query that declares a new argument/variable and references this argument in 4 places in the query. This results in the query crashing with this error message. If instead i keep only 1 reference of the variable the query works.

Parameter 'authUser' is defined multiple times with different bound values: VariableReference{name='authUser'} != VariableReference{name='authUser'} != VariableReference{name='authUser'} != VariableReference{name='authUser'} != VariableReference{name='authUser'}

And stack trace

org.neo4j.cypherdsl.core.ConflictingParametersException: Parameter 'authUser' is defined multiple times with different bound values: VariableReference{name='authUser'} != VariableReference{name='authUser'} != VariableReference{name='authUser'} != VariableReference{name='authUser'} != VariableReference{name='authUser'} at org.neo4j.cypherdsl.core.ParameterCollectingVisitor.getResult(ParameterCollectingVisitor.java:94) ~[neo4j-cypher-dsl-2021.0.2.jar:2021.0.2] at org.neo4j.cypherdsl.core.AbstractStatement.collectParameters(AbstractStatement.java:103) ~[neo4j-cypher-dsl-2021.0.2.jar:2021.0.2] at org.neo4j.cypherdsl.core.AbstractStatement.getParameterInformation(AbstractStatement.java:84) ~[neo4j-cypher-dsl-2021.0.2.jar:2021.0.2] at org.neo4j.cypherdsl.core.AbstractStatement.getParameters(AbstractStatement.java:53) ~[neo4j-cypher-dsl-2021.0.2.jar:2021.0.2] at org.neo4j.graphql.handler.BaseDataFetcher.get(BaseDataFetcher.kt:38) ~[neo4j-graphql-java-1.4.0.jar:na] at org.neo4j.graphql.handler.BaseDataFetcher.get(BaseDataFetcher.kt:20) ~[neo4j-graphql-java-1.4.0.jar:na]

Andy2003 commented 2 years ago

@yarc Can you please test with the current master to see if the problem persists? If so can you provide a testcase.