0

My Strapi installation has a GraphQL endpoint at https://dev.schandillia.com/graphql.

Here, I'm trying to execute the following mutation:

mutation updatePost ($id: ID!, $title: String!){
  updatePost(input: {where: {id: $id}, data: {title: $title}}){
    post{
      id
      title
    }
  }
}

As can be seen, this mutation accepts 2 variables. These I am providing thus:

{
  "id": "5ddf9ff327ee7b0915f0ac91"
  "title": "Some random title"
}

For the endpoint to work, the following auth header will be required:

{
  "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkOWVlNDBhNDYyMGNiMzBiZjdhZGVlMyIsImlzQWRtaW4iOnRydWUsImlhdCI6MTU4NTIxNTU2OCwiZXhwIjoxNTg3ODA3NTY4fQ.0xrjVB9cKxiqN6FbvQ-sRV7nmAHNrV_mSD8D7e1g3qw"
}

It's a very simple mutation using which I am attempting to update a post's title field to Some random title. The post is being looked up by its id field which should be 5ddf9ff327ee7b0915f0ac91.

However, this attempt fails with the following output:

{
  "error": {
    "errors": [
      {
        "message": "Variable \"$id\" of required type \"ID!\" was not provided.",
        "locations": [
          {
            "line": 1,
            "column": 21
          }
        ],
        "extensions": {
          "code": "INTERNAL_SERVER_ERROR"
        }
      },
      {
        "message": "Variable \"$title\" of required type \"String!\" was not provided.",
        "locations": [
          {
            "line": 1,
            "column": 31
          }
        ],
        "extensions": {
          "code": "INTERNAL_SERVER_ERROR"
        }
      }
    ]
  }
}

What am I missing here? It says I've not provided it the variables, but I did!

The GraphQL endpoint in action

TheLearner
  • 2,813
  • 5
  • 46
  • 94

0 Answers0