A
A
Andrey Okhotnikov2020-07-20 14:37:52
Frontend
Andrey Okhotnikov, 2020-07-20 14:37:52

Nested upsert in grqphql query?

There is a request with the following parameters

updateSaleChannelAttribute(
      input: {
        rules: { connect: $rules }
      }
    )


$rules is an array with values ​​in each object. values ​​is also an array that needs to be passed like rules through upsert like

that

{
...item
  values: {
    upsert: item.values
  }
}

and I don’t understand how to write it into the request, here is the full request
const UPDATE_CHANNEL_ATTRIBUTE = gql`
  mutation UpdateChannelAttribute(
    $id: ID!
    $code: String!
    $name: String!
    $value: String
    $saleChannelCategories: [ID!]
    $rules: [UpdateSaleChannelAttributeRuleInput!]
    $childs: [SaleChannelAttributeSaleChannelAttribute!]
    $delimeter: String
    $attributes: [ID!]
  ) {
    updateSaleChannelAttribute(
      input: {
        id: $id
        code: $code
        name: $name
        value: $value
        saleChannelCategories: { sync: $saleChannelCategories }
        rules: { upsert: $rules }
        childs: { sync: $childs }
        delimeter: $delimeter
        attributes: { sync: $attributes }
      }
    ) {
      id
      name
      code
      value
      delimeter
      rules {
        id
        rule
        json_mask
        values {
          id
          key
          value
          type
        }
      }
      childs {
        id
      }
      attributes {
        id
        name
        code
      }

      saleChannelCategories {
        id
        name
        parent {
          id
          name
          parent {
            id
            name
          }
        }
        saleChannel {
          id
          name
        }
      }
    }
  }
`;

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question