Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Data Structures | Public Member Functions
Config Class Reference
Inheritance diagram for Config:
ConfigInterface

Data Structures

class  GraphQlReaderTest
 

Public Member Functions

 __construct (DataInterface $data, ConfigElementFactoryInterface $configElementFactory, QueryFields $queryFields)
 
 getConfigElement (string $configElementName)
 
 getDeclaredTypeNames ()
 

Detailed Description

Provides access to typing information for a configured GraphQL schema.

Definition at line 18 of file Config.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( DataInterface  $data,
ConfigElementFactoryInterface  $configElementFactory,
QueryFields  $queryFields 
)
Parameters
DataInterface$data
ConfigElementFactoryInterface$configElementFactory
QueryFields$queryFields

Definition at line 40 of file Config.php.

44  {
45  $this->configData = $data;
46  $this->configElementFactory = $configElementFactory;
47  $this->queryFields = $queryFields;
48  }

Member Function Documentation

◆ getConfigElement()

getConfigElement ( string  $configElementName)

Get a data object with data pertaining to a GraphQL type's structural makeup.

Parameters
string$configElementName
Returns
ConfigElementInterface
Exceptions

Implements ConfigInterface.

Definition at line 58 of file Config.php.

58  : ConfigElementInterface
59  {
60  $data = $this->configData->get($configElementName);
61  if (!isset($data['type'])) {
62  throw new \LogicException(
63  sprintf('Config element "%s" is not declared in GraphQL schema', $configElementName)
64  );
65  }
66 
67  $fieldsInQuery = $this->queryFields->getFieldsUsedInQuery();
68  if (isset($data['fields']) && !empty($fieldsInQuery)) {
69  foreach ($data['fields'] as $fieldName => $fieldConfig) {
70  if (!isset($fieldsInQuery[$fieldName])) {
71  unset($data['fields'][$fieldName]);
72  }
73  }
74  }
75 
76  return $this->configElementFactory->createFromConfigData($data);
77  }

◆ getDeclaredTypeNames()

getDeclaredTypeNames ( )

Return all type names declared in a GraphQL schema's configuration.

Returns
string[]

Implements ConfigInterface.

Definition at line 84 of file Config.php.

84  : array
85  {
86  $types = [];
87  foreach ($this->configData->get(null) as $item) {
88  if (isset($item['type']) && $item['type'] == 'graphql_type') {
89  $types[] = $item['name'];
90  }
91  }
92  return $types;
93  }

The documentation for this class was generated from the following file: