forked from magento/magento2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow introspection by default in production mode
Adds env.php parameter for disabling introspection: ```php ... 'graphql' => [ 'disable_introspection' => true, ], ... ``` Fixes magento#232
- Loading branch information
Showing
3 changed files
with
57 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
lib/internal/Magento/Framework/GraphQl/Query/IntrospectionConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Framework\GraphQl\Query; | ||
|
||
use Magento\Framework\App\DeploymentConfig; | ||
|
||
/** | ||
* Class for fetching the availability of introspection queries | ||
*/ | ||
class IntrospectionConfiguration | ||
{ | ||
const CONFIG_PATH_DISABLE_INTROSPECTION = 'graphql/disable_introspection'; | ||
|
||
/** | ||
* @var DeploymentConfig | ||
*/ | ||
private $deploymentConfig; | ||
|
||
/** | ||
* @param DeploymentConfig $deploymentConfig | ||
*/ | ||
public function __construct( | ||
DeploymentConfig $deploymentConfig | ||
) { | ||
$this->deploymentConfig = $deploymentConfig; | ||
} | ||
|
||
/** | ||
* Check the the environment config to determine if introspection should be disabled. | ||
* | ||
* @return int | ||
*/ | ||
public function disableIntrospection(): int | ||
{ | ||
return (int) $this->deploymentConfig->get(self::CONFIG_PATH_DISABLE_INTROSPECTION); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters