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

Filter arguments as variable #251

Open yarc opened 3 years ago

yarc commented 3 years ago

I'm currently running 1.2.0 in my project and encountered this error while upgrading to 1.4.0.

If i try to use a query variable for a Filter argument, the query crashes.

query test($filter: _UserFilter) { user(filter: $filter) { id name } }

class graphql.language.VariableReference cannot be cast to class graphql.language.ObjectValue (graphql.language.VariableReference and graphql.language.ObjectValue

java.lang.ClassCastException: class graphql.language.VariableReference cannot be cast to class graphql.language.ObjectValue (graphql.language.VariableReference and graphql.language.ObjectValue are in unnamed module of loader 'app') at org.neo4j.graphql.handler.filter.OptimizedFilterHandler.generateFilterQuery(OptimizedFilterHandler.kt:54) ~[neo4j-graphql-java-1.4.0.jar:na] at org.neo4j.graphql.handler.QueryHandler.generateCypher(QueryHandler.kt:116) ~[neo4j-graphql-java-1.4.0.jar:na] at org.neo4j.graphql.handler.BaseDataFetcher.get(BaseDataFetcher.kt:29) ~[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] at com.sherpa.aggregator.core.providers.GraphQLBaseSchemaProvider$Neo4jDataFetcher.fetchData(GraphQLBaseSchemaProvider.java:101) ~[classes/:na] at org.neo4j.graphql.SchemaBuilder$addDataFetcher$$inlined$forEach$lambda$1.get(SchemaBuilder.kt:216) ~[neo4j-graphql-java-1.4.0.jar:na] at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:270) ~[graphql-java-16.2.jar:na] at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:203) ~[graphql-java-16.2.jar:na] at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:60) ~[graphql-java-16.2.jar:na] at graphql.execution.Execution.executeOperation(Execution.java:165) ~[graphql-java-16.2.jar:na] at graphql.execution.Execution.execute(Execution.java:104) ~[graphql-java-16.2.jar:na] at graphql.GraphQL.execute(GraphQL.java:557) ~[graphql-java-16.2.jar:na] at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:482) ~[graphql-java-16.2.jar:na] at graphql.GraphQL.executeAsync(GraphQL.java:446) ~[graphql-java-16.2.jar:na] at graphql.GraphQL.execute(GraphQL.java:377) ~[graphql-java-16.2.jar:na]

Andy2003 commented 3 years ago

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