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.

Writing relationship mutation

schema.graphql

type Person {
  id: ID!
  name: String!
  roll: [Roll] @relation(name: "PLAYING", direction: "OUT")
}

type Roll {
  id: ID!
  type: String!
  name: String!
  person: [Person] @relation(name: "PLAYING", direction: "IN")
}

type Query {
  personsBySubstring(substring: String!): [Person]
    @cypher(
      statement: "MATCH (u:Person) WHERE u.name CONTAINS $substring RETURN u"
    )
}

Schema in playground shows

AddPersonRoll(
from: _PersonInput!
to: _RollInput!
): _AddPersonRollPayload

This works

mutation {
  AddPersonRoll(
    from: {
      id: "be91aaca-944d-49f7-b3fd-c89ad454d5ab"
    }
    to: {
        id: "8726255f-b6b6-4299-ba01-95f6d4ef2be7"
    }
  ) { 
    from {
      id
      name
    }

    to {
      id
      name
    }
  }
}

But I need to use variables. tried ...

mutation AddPersonRoll($PersonInput: ID!, $RollInput: ID!){
  AddPersonRoll(
    from: {
      id: $PersonInput
    }
    to: {
        id: $RollInput
    }
  ) { 
    from {
      id
      name
    }

    to {
      id
      name
    }
  }
}


{
  "PersonInput": "3cc70aca-9e07-4bbd-acb2-92670b4d1b0d",
  "RollInput": "8726255f-b6b6-4299-ba01-95f6d4ef2be7"
}

keep getting this

{
  "error": {
    "errors": [
      {
        "message": "Variable \"$PersonInput\" of required type \"ID!\" was not provided.",
        "locations": [
          {
            "line": 1,
            "column": 24
          }
        ],

How can I fix it?

1 ACCEPTED SOLUTION

I got it. I put the var in the headers area. opps

View solution in original post

1 REPLY 1

I got it. I put the var in the headers area. opps