Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

128 extend store config coverage #130

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
a00df27
graphql-ce-128: added extended store config dataprovider
Jul 24, 2018
5ad0774
Merge branch '2.3-develop' of https://github.com/magento/graphql-ce i…
Jul 24, 2018
3872187
graphql-ce-128: fixed return types
Jul 24, 2018
efe6091
graphql-ce-128: added test for extended configs
Jul 24, 2018
f82bd47
graphql-ce-128: fixed the way to define current store
Jul 26, 2018
9d7f217
GraphQL-128: refactored extended configs, added CmsGraphQl and ThemeG…
Jul 30, 2018
b84844f
GraphQL-128: static fixes, removed test
Aug 2, 2018
8355529
GraphQL-128: added new modules to root composer json
Aug 2, 2018
43b178e
GraphQL-128: updated composer.lock
Aug 2, 2018
1a8fef4
Test coverage for CMS page
TomashKhamlai Aug 21, 2018
8f936ac
Fix problems reported by testCodeStyle
TomashKhamlai Aug 21, 2018
56d6801
Test coverage for CMS block
TomashKhamlai Aug 21, 2018
b85ec3f
Reformat code
TomashKhamlai Aug 22, 2018
2d3b311
Reformat again
TomashKhamlai Aug 22, 2018
8b2731f
Test coverage for added breadcrumbs support #158
TomashKhamlai Aug 23, 2018
af69563
Allow scalars as resolver return type.
sourabh-ranosys Aug 26, 2018
fbff94b
Modified to allow scalars as resolver return type
sourabh-ranosys Aug 26, 2018
d49ef93
Changes to allow scalars as resolver return type.
sourabh-ranosys Aug 26, 2018
b2d22d0
GraphQL-152: Allow scalars as resolver return type
Sep 5, 2018
b6c6cba
GraphQL-152: Allow scalars as resolver return type
Sep 5, 2018
157546b
Merge branch 'GraphQL-165' into GraphQL-152-165
Sep 5, 2018
820157a
GraphQL-152: Allow scalars as resolver return type
Sep 5, 2018
7159ad2
GraphQL-128: added magentoApiConfig fixture annotation support in tes…
Sep 9, 2018
14cf51a
GraphQL-128: fixed static issue
Sep 10, 2018
516a22d
GraphQL-167: added support for @magentoApiConfigFixture
Sep 10, 2018
1b41bfe
Merge remote-tracking branch 'origin/2.3-develop' into GraphQL-152-165
Sep 11, 2018
1ae2b99
Merge remote-tracking branch 'origin/graphql-ce-151-block' into Graph…
Sep 11, 2018
bee1824
Merge remote-tracking branch 'origin/graphql-ce-151-page' into GraphQ…
Sep 11, 2018
487113f
Merge remote-tracking branch 'origin/graphql-ce-158' into GraphQL-172
Sep 11, 2018
ee9adad
GraphQL-172: GraphQL modules delivery
Sep 11, 2018
7ab6968
Merge branches '128-extend-store-config-coverage' and 'GraphQL-172' o…
Sep 11, 2018
5d99845
GraphQL-128: updated lock file
Sep 11, 2018
6b492d5
GraphQL-128: removed accidentally added file
Sep 11, 2018
4a3e4eb
Merge branches '128-extend-store-config-coverage' and '167-magento-co…
Sep 11, 2018
2fda32c
GraphQL-128: uskiped and fixed inventory test
Sep 11, 2018
12236ce
GraphQL-128: removed unused injection
Sep 11, 2018
b620cf4
Merge remote-tracking branch 'origin/2.3-develop' into 128-extend-sto…
Sep 12, 2018
7bcd0ec
GraphQL-130: Extend store config coverage
Sep 12, 2018
f6f673f
GraphQL-130: Extend store config coverage
Sep 12, 2018
fec5e1f
GraphQL-130: Extend store config coverage
Sep 12, 2018
a9343b8
Merge branches '128-extend-store-config-coverage' and '2.3-develop' o…
Sep 12, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/code/Magento/CmsGraphQl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# CmsGraphQl

**CmsGraphQl** provides type information for the GraphQl module
to generate CMS fields information endpoints.
25 changes: 25 additions & 0 deletions app/code/Magento/CmsGraphQl/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "magento/module-cms-graph-ql",
"description": "N/A",
"type": "magento2-module",
"require": {
"php": "~7.1.3||~7.2.0",
"magento/framework": "*"
},
"suggest": {
"magento/module-graph-ql": "*",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have dependency on CMS module (or at least suggest, if there are no hard dependencies)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi
I guess Travis will fail in this case with the "redundant dependency" error.

"magento/module-store-graph-ql": "*"
},
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Magento\\CmsGraphQl\\": ""
}
}
}
21 changes: 21 additions & 0 deletions app/code/Magento/CmsGraphQl/etc/graphql/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\StoreGraphQl\Model\Resolver\Store\ExtendedStoreConfigDataProvider">
<arguments>
<argument name="extendedConfigs" xsi:type="array">
<item name="front" xsi:type="string">web/default/front</item>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to replace value on constants

<item name="cms_home_page" xsi:type="string">web/default/cms_home_page</item>
<item name="no_route" xsi:type="string">web/default/no_route</item>
<item name="cms_no_route" xsi:type="string">web/default/cms_no_route</item>
<item name="cms_no_cookies" xsi:type="string">web/default/cms_no_cookies</item>
<item name="show_cms_breadcrumbs" xsi:type="string">web/default/show_cms_breadcrumbs</item>
</argument>
</arguments>
</type>
</config>
14 changes: 14 additions & 0 deletions app/code/Magento/CmsGraphQl/etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_CmsGraphQl">
<sequence>
<module name="Magento_GraphQl"/>
</sequence>
</module>
</config>
10 changes: 10 additions & 0 deletions app/code/Magento/CmsGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.
type StoreConfig @doc(description: "The type contains information about a store config") {
front : String @doc(description: "Default Web URL")
cms_home_page : String @doc(description: "CMS Home Page")
no_route : String @doc(description: "Default No-route URL")
cms_no_route : String @doc(description: "CMS No Route Page")
cms_no_cookies : String @doc(description: "CMS No Cookies Page")
show_cms_breadcrumbs : Int @doc(description: "Show Breadcrumbs for CMS Pages")
}
10 changes: 10 additions & 0 deletions app/code/Magento/CmsGraphQl/registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_CmsGraphQl', __DIR__);
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\StoreGraphQl\Model\Resolver\Store;

use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Store\Model\ScopeInterface;

/**
* Extends default StoreConfigInterface for GraphQL request processing.
*/
class ExtendedStoreConfigDataProvider
{
/**
* @var ScopeConfigInterface
*/
private $scopeConfig;

/**
* @var array
*/
private $extendedConfigs;

/**
* @param ScopeConfigInterface $scopeConfig
* @param array $extendedConfigs
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
array $extendedConfigs
) {
$this->scopeConfig = $scopeConfig;
$this->extendedConfigs = $extendedConfigs;
}

/**
* Get data from ScopeConfig by path's defined in DI config
* @return array
*/
public function getExtendedConfigs()
{
$extendedConfigsData = [];
foreach ($this->extendedConfigs as $key => $path) {
$extendedConfigsData[$key] = $this->scopeConfig->getValue($path, ScopeInterface::SCOPE_STORE);
}

return $extendedConfigsData;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@

use Magento\Store\Api\Data\StoreConfigInterface;
use Magento\Store\Api\StoreConfigManagerInterface;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\StoreManagerInterface;

/**
* StoreConfig field data provider, used for GraphQL request processing.
Expand All @@ -23,28 +22,20 @@ class StoreConfigDataProvider
private $storeConfigManager;

/**
* @var StoreResolverInterface
* @var StoreManagerInterface
*/
private $storeResolver;

/**
* @var StoreRepositoryInterface
*/
private $storeRepository;
private $storeManager;

/**
* @param StoreConfigManagerInterface $storeConfigManager
* @param StoreResolverInterface $storeResolver
* @param StoreRepositoryInterface $storeRepository
* @param StoreManagerInterface $storeManager
*/
public function __construct(
StoreConfigManagerInterface $storeConfigManager,
StoreResolverInterface $storeResolver,
StoreRepositoryInterface $storeRepository
StoreManagerInterface $storeManager
) {
$this->storeConfigManager = $storeConfigManager;
$this->storeResolver = $storeResolver;
$this->storeRepository = $storeRepository;
$this->storeManager = $storeManager;
}

/**
Expand All @@ -54,11 +45,10 @@ public function __construct(
*/
public function getStoreConfig() : array
{
$storeId = $this->storeResolver->getCurrentStoreId();
$store = $this->storeRepository->getById($storeId);
$store = $this->storeManager->getStore();
$storeConfig = current($this->storeConfigManager->getStoreConfigs([$store->getCode()]));

return $this->hidrateStoreConfig($storeConfig);
return $this->hydrateStoreConfig($storeConfig);
}

/**
Expand All @@ -67,7 +57,7 @@ public function getStoreConfig() : array
* @param StoreConfigInterface $storeConfig
* @return array
*/
private function hidrateStoreConfig($storeConfig): array
private function hydrateStoreConfig($storeConfig): array
{
/** @var StoreConfigInterface $storeConfig */
$storeConfigData = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\StoreGraphQl\Model\Resolver\Store\ExtendedStoreConfigDataProvider;
use Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider;

/**
Expand All @@ -24,21 +25,29 @@ class StoreConfigResolver implements ResolverInterface
*/
private $storeConfigDataProvider;

/**
* @var ExtendedStoreConfigDataProvider
*/
private $extendedStoreConfigsDataProvider;

/**
* @var ValueFactory
*/
private $valueFactory;

/**
* @param StoreConfigDataProvider $storeConfigsDataProvider
* @param ExtendedStoreConfigDataProvider $extendedStoreConfigsDataProvider
* @param ValueFactory $valueFactory
*/
public function __construct(
StoreConfigDataProvider $storeConfigsDataProvider,
ExtendedStoreConfigDataProvider $extendedStoreConfigsDataProvider,
ValueFactory $valueFactory
) {
$this->valueFactory = $valueFactory;
$this->storeConfigDataProvider = $storeConfigsDataProvider;
$this->extendedStoreConfigsDataProvider = $extendedStoreConfigsDataProvider;
}

/**
Expand All @@ -52,7 +61,10 @@ public function resolve(
array $args = null
) : Value {

$storeConfigData = $this->storeConfigDataProvider->getStoreConfig();
$storeConfigData = array_merge(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use just one config provider and the list of accessible fields should be filtered according to the extensible di.xml

Copy link
Contributor Author

@VitaliyBoyko VitaliyBoyko Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @paliarush
God point
But, the decision with one config provider doesn't right here.
We getting configs from different sources, StoreConfigDataProvider gets data from StoreConfigInterface unlike ExtendedStoreConfigDataProvider which gets data from ScopeConfigInterface.
It is not possible to get all StoreConfigInterface fields from ScopeConfigInterface.
For example base_url not present in core_config_data and defines in app/code/Magento/Store/Model/Store.php:607.

$this->storeConfigDataProvider->getStoreConfig(),
$this->extendedStoreConfigsDataProvider->getExtendedConfigs()
);

$result = function () use ($storeConfigData) {
return !empty($storeConfigData) ? $storeConfigData : [];
Expand Down
4 changes: 4 additions & 0 deletions app/code/Magento/ThemeGraphQl/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# ThemeGraphQlhQl

**ThemeGraphQlhQl** provides type information for the GraphQl module
to generate theme fields information endpoints.
25 changes: 25 additions & 0 deletions app/code/Magento/ThemeGraphQl/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "magento/module-theme-graph-ql",
"description": "N/A",
"type": "magento2-module",
"require": {
"php": "~7.1.3||~7.2.0",
"magento/framework": "*"
},
"suggest": {
"magento/module-graph-ql": "*",
"magento/module-store-graph-ql": "*"
},
"license": [
"OSL-3.0",
"AFL-3.0"
],
"autoload": {
"files": [
"registration.php"
],
"psr-4": {
"Magento\\ThemeGraphQlhQl\\": ""
}
}
}
36 changes: 36 additions & 0 deletions app/code/Magento/ThemeGraphQl/etc/graphql/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\StoreGraphQl\Model\Resolver\Store\ExtendedStoreConfigDataProvider">
<arguments>
<argument name="extendedConfigs" xsi:type="array">
<!-- Begin Design Configuration HTML Head Section-->
<item name="head_shortcut_icon" xsi:type="string">design/head/head_shortcut_icon</item>
<item name="default_title" xsi:type="string">design/head/default_title</item>
<item name="title_prefix" xsi:type="string">design/head/title_prefix</item>
<item name="title_suffix" xsi:type="string">design/head/title_suffix</item>
<item name="default_description" xsi:type="string">design/head/default_description</item>
<item name="default_keywords" xsi:type="string">design/head/default_keywords</item>
<item name="head_includes" xsi:type="string">design/head/includes</item>
<item name="demonotice" xsi:type="string">design/head/demonotice</item>
<!-- End Design Configuration HTML Head Section -->
<!-- Begin Design Configuration Header Section-->
<item name="header_logo_src" xsi:type="string">design/header/header_logo_src</item>
<item name="logo_width" xsi:type="string">design/header/logo_width</item>
<item name="logo_height" xsi:type="string">design/header/logo_height</item>
<item name="welcome" xsi:type="string">design/header/welcome</item>
<item name="logo_alt" xsi:type="string">design/header/logo_alt</item>
<!-- End Design Configuration Header Section -->
<!-- Begin Design Configuration Footer Section-->
<item name="copyright" xsi:type="string">design/footer/copyright</item>
<item name="absolute_footer" xsi:type="string">design/footer/absolute_footer</item>
<!-- End Design Configuration Footer Section -->
</argument>
</arguments>
</type>
</config>
14 changes: 14 additions & 0 deletions app/code/Magento/ThemeGraphQl/etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Magento_ThemeGraphQl">
<sequence>
<module name="Magento_GraphQl"/>
</sequence>
</module>
</config>
19 changes: 19 additions & 0 deletions app/code/Magento/ThemeGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.
type StoreConfig @doc(description: "The type contains information about a store config") {
head_shortcut_icon : String @doc(description: "Favicon Icon")
default_title : String @doc(description: "Default Page Title")
title_prefix : String @doc(description: "Page Title Prefix")
title_suffix : String @doc(description: "Page Title Suffix")
default_description : String @doc(description: "Default Meta Description")
default_keywords : String @doc(description: "Default Meta Keywords")
head_includes : String @doc(description: "Scripts and Style Sheets")
demonotice : Int @doc(description: "Display Demo Store Notice")
header_logo_src : String @doc(description: "Logo Image")
logo_width : Int @doc(description: "Logo Attribute Width")
logo_height : Int @doc(description: "Logo Attribute Height")
welcome : String @doc(description: "Welcome Text")
logo_alt : String @doc(description: "Logo Image Alt")
absolute_footer : String @doc(description: "Footer Miscellaneous HTML")
copyright : String @doc(description: "Copyright")
}
10 changes: 10 additions & 0 deletions app/code/Magento/ThemeGraphQl/registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

use Magento\Framework\Component\ComponentRegistrar;

ComponentRegistrar::register(ComponentRegistrar::MODULE, 'Magento_ThemeGraphQl', __DIR__);
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"magento/module-checkout": "*",
"magento/module-checkout-agreements": "*",
"magento/module-cms": "*",
"magento/module-cms-graph-ql": "*",
"magento/module-cms-url-rewrite": "*",
"magento/module-config": "*",
"magento/module-configurable-import-export": "*",
Expand Down Expand Up @@ -213,6 +214,7 @@
"magento/module-tax": "*",
"magento/module-tax-import-export": "*",
"magento/module-theme": "*",
"magento/module-theme-graph-ql": "*",
"magento/module-translation": "*",
"magento/module-ui": "*",
"magento/module-ups": "*",
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading