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.

Invalid input 'on': expected\n \"*\"\n \"]\"\n \"{\"\n \"|\"\n a parameter while creating mutations

 

I have created a neo4j graphql API which does CRUD operations and was trying to implement mutations but i am receiving this error and don't know why this is happening.

I am not facing any problem implementing mutations from this page. But when I try my own example I am getting this error and unable to resolve it.

{
  "errors": [
    {
      "message": "Invalid input 'on': expected\n  \"*\"\n  \"]\"\n  \"{\"\n  \"|\"\n  a parameter (line 11, column 26 (offset: 360))\n\"MERGE (this0)-[:Activity on]->(this0_activityonDisease0_node)\"\n                          ^",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "createUsers"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "code": "Neo.ClientError.Statement.SyntaxError",
          "name": "Neo4jError",
          "stacktrace": [
            "Neo4jError: Invalid input 'on': expected",
            "  \"*\"",
            "  \"]\"",
            "  \"{\"",
            "  \"|\"",
            "  a parameter (line 11, column 26 (offset: 360))",
            "\"MERGE (this0)-[:Activity on]->(this0_activityonDisease0_node)\"",
            "                          ^",
            "",
            "    at captureStacktrace (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\result.js:239:17)",
            "    at new Result (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\result.js:59:23)",
            "    at newCompletedResult (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\transaction.js:433:12)",
            "    at Object.run (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\transaction.js:287:20)",
            "    at Transaction.run (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\neo4j-driver-core\\lib\\transaction.js:137:34)",
            "    at execute (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\@neo4j\\graphql\\dist\\utils\\execute.js:87:51)",
            "    at resolve (C:\\Users\\DELL\\Documents\\GitHub\\graphql-testing\\node_modules\\@neo4j\\graphql\\dist\\schema\\resolvers\\mutation\\create.js:34:57)",
            "    at processTicksAndRejections (internal/process/task_queues.js:95:5)"
          ]
        }
      }
    }
  ],
  "data": null
}

type definitions and mutations I am using are given below.

const typeDefs = gql`
type Disease {
    name: String
    medication: String
    period: String
    userActivityon: User @relationship(type: "Activity on", direction: IN)
  }
  
  type User {
    name: String
    age: Int
    sex: String
    weight: Int
    smoking: Boolean
    drinking: Boolean
    nationality: String
    birth_type: String
    activityonDisease: Disease @relationship(type: "Activity on", direction: OUT)
  }
`;
mutation{
  createUsers(input: {
    name:"harsha"
    age:22
    sex:"male"
    activityonDisease:{create:{node:{
      name:"cold"
      medication:"months"
      }}}
  }) {
    users {
      name
      age
      activityonDisease {
        name
        medication
      }
    }
  }
}

can some one point out where I am doing wrong.

1 REPLY 1

your problem is right here:

-[:Activity on]

It is the 'on' part that is not valid syntax.  What are you trying to do here?