cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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
@cypher(
statement: """
$input
"""
)
}

3 REPLIES 3

William_Lyon
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.

Thanks

Any way to provide n:$input.label ?