| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPGraphQL; |
| 4 |
|
| 5 |
use GraphQL\Type\Schema; |
| 6 |
use GraphQL\Type\SchemaConfig; |
| 7 |
use WPGraphQL\Registry\TypeRegistry; |
| 8 |
|
| 9 |
/** |
| 10 |
* Class WPSchema |
| 11 |
* |
| 12 |
* Extends the Schema to make some properties accessible via hooks/filters |
| 13 |
* |
| 14 |
* @package WPGraphQL |
| 15 |
*/ |
| 16 |
class WPSchema extends Schema { |
| 17 |
/** |
| 18 |
* {@inheritDoc} |
| 19 |
* |
| 20 |
* @var \GraphQL\Type\SchemaConfig |
| 21 |
*/ |
| 22 |
public $config; |
| 23 |
|
| 24 |
/** |
| 25 |
* Holds the $filterable_config which allows WordPress access to modifying the |
| 26 |
* $config that gets passed down to the Executable Schema |
| 27 |
* |
| 28 |
* @var \GraphQL\Type\SchemaConfig |
| 29 |
* @since 0.0.9 |
| 30 |
*/ |
| 31 |
public $filterable_config; |
| 32 |
|
| 33 |
/** |
| 34 |
* WPSchema constructor. |
| 35 |
* |
| 36 |
* @param \GraphQL\Type\SchemaConfig $config The config for the Schema. |
| 37 |
* @param \WPGraphQL\Registry\TypeRegistry $type_registry |
| 38 |
* |
| 39 |
* @since 0.0.9 |
| 40 |
*/ |
| 41 |
public function __construct( SchemaConfig $config, TypeRegistry $type_registry ) { |
| 42 |
$this->config = $config; |
| 43 |
|
| 44 |
/** |
| 45 |
* Set the $filterable_config as the $config that was passed to the WPSchema when instantiated |
| 46 |
* |
| 47 |
* @param \GraphQL\Type\SchemaConfig $config The config for the Schema. |
| 48 |
* @param \WPGraphQL\Registry\TypeRegistry $type_registry The WPGraphQL type registry. |
| 49 |
* |
| 50 |
* @hookGroup schema-registration |
| 51 |
* @since 0.0.9 |
| 52 |
*/ |
| 53 |
$this->filterable_config = apply_filters( 'graphql_schema_config', $config, $type_registry ); |
| 54 |
parent::__construct( $this->filterable_config ); |
| 55 |
} |
| 56 |
} |
| 57 |
|