Showing results for 
Search instead for 
Did you mean: 

Anyway to pass dynamic cypher query as input variable in graphql

anyway to pass dynamic complete cypher query as input variable in graphql
like below .my cypher query changes dynamically so looking for some dynamic approach while defining graphql schema.

type Customer {
basic_count(input: String): String
statement: """


Graph Fellow

Yes, any field arguments defined in a Cypher directive GraphQL field are passed as Cypher parameters to the Cypher query defined in the directive. For example:

type Query {
  movieSearch(searchTerm: String!): [Movie] @cypher(statement: """
    MATCH (m:Movie) WHERE m.title CONTAINS $searchTerm
    RETURN m

There's a bit more info in the docs here: @cypher directive - Neo4j GraphQL Library

As an aside, if you are looking to calculate the total number of nodes matching some filter you may benefit from the auto-generated count queries: Queries - Neo4j GraphQL Library

Thanks for response!
I was able to run such schema where i can pass $searchTerm as a input parameter

but i want to pass Whole cypher statement as a input parameter , because in many scenarios i am not aware about node and properties values in advance.


Nodes 2022
NODES 2022, Neo4j Online Education Summit

On November 16 and 17 for 24 hours across all timezones, you’ll learn about best practices for beginners and experts alike.