eggate/chalhoub-shopfinder-graph-ql

Chalhob_Shopfinder 模块的 GraphQL 端点

1.0.0 2023-01-19 12:52 UTC

This package is not auto-updated.

Last update: 2024-09-27 18:46:41 UTC


README

本模块应暴露 Chalhob_Shopfinder 模块的 GraphQL API。

安装

使用 Composer 安装扩展

  composer require eggate/chalhoub-shopfinder-graph-ql

运行 Magento 安装命令

  bin/magento setup:install
  bin/magento setup:di:compile
  bin/magento setup:static-content:deploy --area adminhtml
  bin/magento cache:flush

功能

  • 我们应该能够使用任何 GraphQL 演练场。
  • 我们应该能够使用查询来获取所有商店。
  • 我们应该能够使用突变来更新任何商店信息。
  • 我们不应能够通过 API 删除商店 - 为此情况提供适当的错误处理。
  • 我们应该能够使用查询根据标识符获取单个商店的信息。
  • (可选) 我们应该能够根据我的当前位置获取附近的商店。

GraphQL API 参考

获取所有商店/过滤后的商店

  query {
    Shops(
        currentPage: ${currentPage}
        pageSize: ${pageSize}
        input: {
            identifier: "filter by identifier"
            name : "filter by name"
            shop_ids: "filter by ids"
        }
    ){
        total_count
        items{
            shop_id
            name
            identifier
            image
            country_id
            latitude
            longitude
        }
    }
}

ShopFilterInput 架构

通过标识符获取商店

  query {
    Shop(
      identifier: ${identifier}
    ){
        shop_id
        name
        identifier
        image
        country_id
        latitude
        longitude
    }
}

根据位置获取最近商店(哈夫斯文方程)距离(公里)

  query {
    nearestShops(
        currentPage: 1
        pageSize: 20
        coords: {
            lat: "location latitude"
            long : "location longitude"
            radius: "search radius"
        }
    ){
        total_count
        items{
            shop_id
            name
            identifier
            image
            country_id
            latitude
            longitude
        }
    }
}

保存新商店或更新现有商店

mutation{
    saveShop(
        shop:{
            shop_id : ${shop_id}
            name: ${name}
            identifier: ${identifier}
            image: ${image}
            country_id: ${country_id}
            latitude: ${latitude}
            longitude: ${longitude}
        }
    ){
        shop {
            shop_id
            name
            identifier
            image
            country_id
            latitude
            longitude
        }
    }
}

通过 ID 或标识符删除商店

mutation{
    deleteShop(
        filter:{
            shop_id : ${shop_id}
            identifier: ${identifier}
        }
    ){
        message
    }
}

仅提供 1 个过滤器参数