Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing array on GraphQL

Tags:

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.

like image 448
p.magalhaes Avatar asked May 17 '17 04:05

p.magalhaes


1 Answers

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

like image 169
Locco0_0 Avatar answered Oct 21 '22 09:10

Locco0_0