How to send relationship type as a parameter from controller to the query using spring boot

@Query("Match(a:Author{name:{0}})"
+ "Merge(b:Book{name:{1}})"
+ "Merge(a)-[r:{2}]->(b) return a,b,r")
public Author comprisesto(String startNode, String endNode, String relation);

controller code
@GetMapping("/createRelationship")
public String CreateRelationship(@RequestParam String startNode,@RequestParam String endNode,@RequestParam String relationship)
{

	   String relation=NodeMapper.getRelation(startNode, endNode);
	   RelationService rs = new RelationService();
	   rs.createRelation(startNode, endNode, relationship) ;
	   return relation;	 
}

error i got:

org.springframework.dao.InvalidDataAccessResourceUsageException: Cypher execution failed with code 'Neo.ClientError.Statement.SyntaxError': Invalid input '{': expected whitespace or a rel type name (line 1, column 80 (offset: 79))
"Match(a:Author{name:{0}}) Merge(b:Book{name:{1}}) Merge(a)-[r:{2}]->(b) return a,b,r"
^.; nested exception is org.neo4j.ogm.exception.CypherException: Cypher execution failed with code 'Neo.ClientError.Statement.SyntaxError':
Invalid input '{': expected whitespace or a rel type name (line 1, column 80 (offset: 79))
"Match(a:Author{name:{0}}) Merge(b:Book{name:{1}}) Merge(a)-[r:{2}]->(b) return a,b,r"

@shashireddy055,
Your query has syntax error

  1. "Match(a:Author{name:{0}})" --> What do you mean by {0}
  2. "Merge(b:Book{name:{1}})" --> What do you mean by {1}
  3. Merge(a)-[r:{2}]->(b) return a,b,r" --> You need to provide relationship type when colon symbol is used also {2}

Visit below link
https://docs.spring.io/spring-data/data-neo4j/docs/current/reference/html/#reference
@Query("MATCH (:Actor {name:$name})-[:ACTED_IN]->(m:Movie) return m")

Reltypes and labels cannot be parameterized.

You could use type(r) = $type
But that’s not as efficient

Otherwise construct the query string and use the template for querying

Just learned it works with SPEL

can u give me an example for this. I am familiar with using template

See the example for SPEL (Spring Expression Language above)