p.magalhaes
p.magalhaes

Reputation: 8374

Passing array on GraphQL

I've this kind of mutation:

mutation updateProducts($input1 : ProductInput!, $id1: ID!, $input2 : ProductInput!, $id2: ID!){
  p1: updateProduct(productInput: $input1, id: $id1){
      product{
      id
      showcaseOrder
    }

  }
enter code here
  p2: updateProduct(productInput: $input2, id: $id2){
      product{
      id
      showcaseOrder
    }
  }     

}

I am setting this variables:

{
  "input1": {
    "showcaseOrder": 2
  },
  "id1": "363",
  "input2": {
    "showcaseOrder": 1
  },
  "id2": "364"
}

I would like to pass an array with all information to the query instead of pass one by one.

Upvotes: 8

Views: 19384

Answers (1)

Locco0_0
Locco0_0

Reputation: 3500

You could define an input type for the mutation which takes all the values. Please take a look at this cheat sheet.

Or for example this post

Upvotes: 8

Related Questions