oxid-academy / graphql-product
Description of the package.
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:oxideshop-module
Requires
- php: ^7.4
- oxid-esales/graphql-base: ^5.2
This package is auto-updated.
Last update: 2025-02-13 17:46:58 UTC
README
This module shows how to implement your own queries and mutations.
Install
composer require oxid-academy/graphql-product vendor/bin/oe-console oe:module:activate oe_graphql_base vendor/bin/oe-console oe:module:activate oxac_graphql_product
[ ! ] The modules Storefront and/or oxid-academy/graphql-product-extension must be deactivated:
vendor/bin/oe-console oe:module:deactivate oe_graphql_storefront vendor/bin/oe-console oe:module:deactivate oxac_graphql_productextension
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=0
Request
query {
product (itemNumber: "1402") {
itemNumber,
title
}
}
Response
{
"data": {
"product": {
"itemNumber": "1402",
"title": "Trapez ION MADTRIXX"
}
}
}
Mutation
URL: http://localhost/graphql/?shp=1&lang=0
Request
mutation{
changeTitle(itemNumber: "1501", title: "Changed Title")
}
Response
{
"data": {
"changeTitle": "0584e8b766a4de2177f9ed11d1587f55"
}
}
Sources
- Background knowledge about the architecture of the module and the GraphQL Modules, since it differs to the eShop
Framework.
https://madewithlove.com/blog/software-engineering/hexagonal-architecture-demystified/ - The GraohQL Module documentation contains a tutorial which describes how to write own queries and mutations. Based of
this documentation this example module was written.
https://docs.oxid-esales.com/interfaces/graphql/en/latest/tutorials/introduction.html