【问题标题】:GraphQL implimentation with Shopify using Java使用 Java 与 Shopify 实现 GraphQL
【发布时间】:2018-12-06 05:26:43
【问题描述】:

我正在构建一个 Shopify 应用,该应用需要调整 Shopify 中的产品库存。 Shopify 即将使用 admin/product.json 弃用其库存调整 POST 调用,并将更新为 /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
    }
  }
}

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

【问题讨论】:

  • 这个问题已经被问过很多次了。简而言之,寻找 Shopify 的 Graphql Java Generator 或 Apollo Android(不是 Android 特定的,尽管有这个名字)。

标签: java shopify graphql shopify-app graphql-java


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2017-11-18
    • 2016-12-20
    • 2019-03-22
    • 2019-10-12
    • 2021-06-18
    • 2020-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多