1

我有来自 shopify graphql 的以下突变,以向现有产品添加变体

询问

mutation UpdateProductMutation ($id: ID!, $options: [String!], $variants: [ProductVariantInput!]) {
  productUpdate(input: {id: $id, options: $options, variants: $variants}) {
    product {
      id,
      title,
      publishedAt,
      options {
        values
      }
      variants(first: 100) {
        edges {
          node {
            id,
            title
          }
        }
      }
    }
    userErrors {
      field,
      message
    }
  }
}

价值观

{
    "id": "gid://shopify/Product/5388344426634",
    "options": [
        "size",
        "color"
    ],
    "variants": [
        {
            "options": [
                "xxl",
                "black"
            ]
        }
    ]
}

回复

{
  "data": {
    "productUpdate": {
      "product": {
        "id": "gid:\/\/shopify\/Product\/5388344426634",
        "title": "hello-kitty123s",
        "publishedAt": null,
        "options": [
          {
            "values": [
              "xxl"
            ]
          },
          {
            "values": [
              "black"
            ]
          }
        ],
        "variants": {
          "edges": [
            {
              "node": {
                "id": "gid:\/\/shopify\/ProductVariant\/34937293373578",
                "title": "xxl \/ black"
              }
            }
          ]
        }
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 113,
      "actualQueryCost": 14,
      "throttleStatus": {
        "maximumAvailable": 1000.0,
        "currentlyAvailable": 986,
        "restoreRate": 50.0
      }
    }
  }
}

有没有一种方法可以让我在响应中只获得新创建的产品变体,而不必对变体进行分页或在查询中传递一个非常大的数字,即variants(first: 100)

4

0 回答 0