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.

How do I pass parameters when calling apoc.cypher.runFile

While calling through the following query in neo4jBrowser
call apoc.cypher.runFile("toolQuery.cyp",{parameters: {transitionType: 'SERVICEDESK'}})

There were no response no record and no changes exist. But without parameter , its working as expected.

Note: - toolQuery.cyp has contain my cypher query details. here is the parameter query am passing MATCH p=(n)-[r:$transitionType]->(m).
kindly go through is there any mistake i did.

9 REPLIES 9

Hello @mr.gsk0509 and welcome to the Neo4j community

You can't set a relationship type or a label from a parameter

Regards,
Cobra

Thank you. Is there any another way of achieve this?

While you can't use parameters as labels directly, you can use CALL apoc.create.addLabels( [node,id,ids,nodes], ['Label',…​]) to apply labels based on an array of values, and those array of values can come from parameters.

Example - this won't work:

MATCH (n) where id(n) = 3
SET n:$LabelParameter
RETURN n

This should work:

CALL apoc.create.addLabels([3], [$LabelParameter]);

What are you trying to achieve with your Cypher file?

Dynamic relationship data will change from my frontend. so, I have to pass the parameter in this cypher query.But this below syntax didn't work in neo browser ,

call apoc.cypher.runFile("toolQuery.cyp",{parameters: {transitionType: 'xxx'}})

transitionType would be xxx, yyy or zzz ..

You want to create relationships?

No. Node,labels and relationships are already created in neo4j db.

Only need to call apoc.cypher.runFile("toolQuery.cyp",{parameters: {transitionType: 'xxx'}})
with following param of either xxx, yyy or zzz.
dynamically cypher query should accept the either of this value.
MATCH p=(n)-[r:$transitionType]->(m)

Try:

MATCH p=(n)-[r]->(m) WHERE type(r) = $transitionType

Tried its working cobra. Thank you very much.