4

我正在构建一个 Shopify 应用程序,它需要调整 Shopify 中的产品库存。Shopify 即将弃用其库存调整 POST 调用admin/product.json,并将更新为/admin/inventory_levels/adjust.json,但新的库存调整 POST 调用允许一次仅更新单个库存水平。但是我的应用程序需要在某个特定时间点更新多个库存级别,因此对每个单独的库存级别进行 POST 调用将占用资源且耗时。当我联系 Shopify 专家时,他建议我将 GraphQL 用于上述目的。我研究了 Java 中的 GraphQL + Shoipfy 实现,但没有找到满意的结果,所以我需要帮助在 Java 中实现 GraphQL 的客户端 POST 调用。下面是我的 GraphQL 结构,我想用 Java 实现

mutation {
  item1: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9229566067?inventory_item_id=10588945219699", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item2: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9229762675?inventory_item_id=10588945219699", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item3: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9229926515?inventory_item_id=10588945219699", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item4: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9645391987?inventory_item_id=10588945219699", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item5: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9645457523?inventory_item_id=10588945219699", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item6: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9645490291?inventory_item_id=10588945219699", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item7: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9229566067?inventory_item_id=10588945252467", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item8: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9229762675?inventory_item_id=10588945252467", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item9: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9229926515?inventory_item_id=10588945252467", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
  item10: inventoryAdjustQuantity(input: {inventoryLevelId: "gid://shopify/InventoryLevel/9645391987?inventory_item_id=10588945252467", availableDelta: 3}) {
    inventoryLevel {
      available
    }
    userErrors {
      field
      message
    }
  }
}

如果您能帮助我解决这个问题或引导我找到一些资源丰富的链接,那就太好了。

4

1 回答 1

0

您可以使用 graphql 管理应用程序在应用程序中运行您的查询。这是一个非常好的应用程序,它还可以帮助您查找参数并识别查询中的错误。 https://shopify-graphiql-app.shopifycloud.com/login

你也可以访问文档来描述我们如何使用 insomnia -> graphql learning kit。您需要在哪里导入集合。我正在使用这个工具来运行 graphql。 https://www.shopify.com/partners/blog/shopify-graphql-learning-kit

于 2019-08-28T10:22:00.497 回答