/graphql-category

Primary LanguagePHPGNU Affero General Public License v3.0AGPL-3.0

About

This is an example module to show a how it would be possible to pull categories with a given SEO url.

Install

composer require oxid-academy/graphql-category
vendor/bin/oe-console oe:module:activate oe_graphql_base
vendor/bin/oe-console oe:module:activate oe_graphql_storefront
vendor/bin/oe-console oe:module:activate oxac_graphql_category

Usage

You can use your favourite GraphQL client to explore the API, if you do not already have one installed, you may use Altair GraphQL Client.

Query

URL: http://localhost/graphql/?shp=1&lang=1

Request

query{
  categoriesBySeo(seo: "Kiteboarding/"){
    title
    children {
      title,
      seo {
        url
      }
    }
  }
}

Response

{
  "data": {
    "categoriesBySeo": [
      {
        "title": "Kiteboarding",
        "children": [
          {
            "title": "Kites",
            "seo": {
              "url": "http://localhost/en/oxid/Kiteboarding/Kites/"
            }
          },
          {
            "title": "Kiteboards",
            "seo": {
              "url": "http://localhost/en/oxid/Kiteboarding/Kiteboards/"
            }
          },
          {
            "title": "Harnesses",
            "seo": {
              "url": "http://localhost/en/oxid/Kiteboarding/Harnesses/"
            }
          },
          {
            "title": "Supplies",
            "seo": {
              "url": "http://localhost/en/oxid/Kiteboarding/Supplies/"
            }
          }
        ]
      }
    ]
  }
}

Sources