From a20c2f13ba2578d788cb741036cfdef2a6e671c6 Mon Sep 17 00:00:00 2001 From: jordan Date: Thu, 28 Mar 2019 11:26:10 +0100 Subject: [PATCH] feat : graphql stores custom --- .../Wazaaa/GraphQL/Model/Resolver/Store.php | 43 +++++++++++++++++++ .../app/code/Wazaaa/GraphQL/etc/module.xml | 9 ++++ .../code/Wazaaa/GraphQL/etc/schema.graphqls | 12 ++++++ .../app/code/Wazaaa/GraphQL/registration.php | 8 ++++ 4 files changed, 72 insertions(+) create mode 100644 www/website/www/app/code/Wazaaa/GraphQL/Model/Resolver/Store.php create mode 100644 www/website/www/app/code/Wazaaa/GraphQL/etc/module.xml create mode 100644 www/website/www/app/code/Wazaaa/GraphQL/etc/schema.graphqls create mode 100644 www/website/www/app/code/Wazaaa/GraphQL/registration.php diff --git a/www/website/www/app/code/Wazaaa/GraphQL/Model/Resolver/Store.php b/www/website/www/app/code/Wazaaa/GraphQL/Model/Resolver/Store.php new file mode 100644 index 0000000..48124c6 --- /dev/null +++ b/www/website/www/app/code/Wazaaa/GraphQL/Model/Resolver/Store.php @@ -0,0 +1,43 @@ +_storeManager = $storeManager; + } + + + /** + * @inheritdoc + */ + public function resolve( + Field $field, + $context, + ResolveInfo $info, + array $value = null, + array $args = null + ) { + $storeManagerDataList = $this->_storeManager->getStores(); + $stores = []; + foreach($storeManagerDataList as $store){ + $stores[] = ['label' => $store->getName(),'code' => $store->getCode(),'id' => $store->getId()]; + } + + return [ + 'total_count' => count($stores), + 'items' => $stores + ]; + } +} \ No newline at end of file diff --git a/www/website/www/app/code/Wazaaa/GraphQL/etc/module.xml b/www/website/www/app/code/Wazaaa/GraphQL/etc/module.xml new file mode 100644 index 0000000..34e3646 --- /dev/null +++ b/www/website/www/app/code/Wazaaa/GraphQL/etc/module.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/www/website/www/app/code/Wazaaa/GraphQL/etc/schema.graphqls b/www/website/www/app/code/Wazaaa/GraphQL/etc/schema.graphqls new file mode 100644 index 0000000..ca39ff8 --- /dev/null +++ b/www/website/www/app/code/Wazaaa/GraphQL/etc/schema.graphqls @@ -0,0 +1,12 @@ +type Query { + getStores:getStoresOutput @resolver(class: "\\Wazaaa\\GraphQL\\Model\\Resolver\\Store") @doc(description: "") +} +type getStoresOutput { + total_count: Int @doc(description: "") + items: [getStore] @doc(description: "") +} +type getStore { + label: String @doc(description: ""), + code: String @doc(description: ""), + id: String @doc(description: ""), +} \ No newline at end of file diff --git a/www/website/www/app/code/Wazaaa/GraphQL/registration.php b/www/website/www/app/code/Wazaaa/GraphQL/registration.php new file mode 100644 index 0000000..0d33920 --- /dev/null +++ b/www/website/www/app/code/Wazaaa/GraphQL/registration.php @@ -0,0 +1,8 @@ +