eggate/chalhoub-shopfinder-graph-ql

GraphQL endpoints for module Chalhob_Shopfinder

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

this module should expose graphql apis for the Chalhoub_Shopfinder module.

Installation

Install extension with composer

  composer require eggate/chalhoub-shopfinder-graph-ql

Run magento installion commands

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

Features

  • We should be able to use any graphql playground.
  • We should be able to use a query to fetch all the shops.
  • We should be able to use a mutation to update any store information.
  • We should not be able to delete stores from the API - Provide aproper error handling for this case.
  • We should be able to use a query to fetch information about a single shop based on the identifier.
  • (Optional) We should be able to fetch the stores near me, based on my current location.

GraphQL API Reference

Get all shops\filtered shops

  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 schema

Get shop by identifier

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

Get nearest shops based on location (Haversine equation) distance in Km

  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
        }
    }
}

Save new or update existing shop

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
        }
    }
}

Delete shop by id or identifier

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

Only provide 1 filter parameter