I have a graph in which I need to execute similar queries repeatedly. I would like to be able to pass parameters to the function and have it return the results.
For instance, let's suppose I have a graph of movies and actors in which I want to find all the movies that an actor has acted in. I can write the following query:
MATCH (actor:Actor)-[:ACTED_IN]->(movie:Movie)
WHERE actor.name = 'Tom Hanks'
RETURN movie.title
Now, I want to reuse this query for different actors as well. Instead of repeating the same query, I want to write a function that takes an actor name as input and returns all the movies that the actor has acted in.