cancel
Showing results forΒ 
Search instead forΒ 
Did you mean:Β 

Mutation to create node with two edges

gclindsey
Node Clone

I have a mutation which is needed to create a Comment node that connects to a User node with matching user handle, and a Project node with matching project ID. Here is the mutation schema:

type Mutation {
  addNewComment(
    commentAuthor: String
    projectId: String
    commentBody: String
  😞 [Comment]
    @cypher(
      statement: """
      MATCH (u:User { userHandle: $commentAuthor })
      MERGE (u)-[:POSTED]->(c:Comment { commentAuthor: u.userHandle, commentBody: 
         $commentBody, projectId: $projectId, commentDate: timestamp() })
      WITH c 
      MATCH (p:Project { projectId: $projectId })
      MERGE (c)-[:ABOUT]->(p) 
      RETURN c.commentAuthor, c.projectId, c.commentBody
      """
    )
}

When I send this query:

mutation newCustomComment {
  addNewComment(
    commentAuthor: "@userhandle"
    projectId: "Project_uid"
    commentBody: "new comment"
  ) {
    commentAuthor
    projectId
    commentBody
  }
}

I get this error:
"String("Project_uid") (of class org.neo4j.values.storable.StringWrappingStringValue)"

Not really sure what's going on but this appears to happen when I add the RETURN statement. I added the RETURN statement because each time I ran the query it created the nodes and relationships alright but didn't return any data. I was hoping to get it to return the relevant data. Any help would be appreciated!

0 REPLIES 0