Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Data Fields
GraphQlReader Class Reference
Inheritance diagram for GraphQlReader:
ReaderInterface

Public Member Functions

 __construct (FileResolverInterface $fileResolver, TypeReaderComposite $typeReader, $fileName=self::GRAPHQL_SCHEMA_FILE, $defaultScope='global')
 
 read ($scope=null)
 

Data Fields

const GRAPHQL_PLACEHOLDER_FIELD_NAME = 'placeholder_graphql_field'
 
const GRAPHQL_SCHEMA_FILE = 'schema.graphqls'
 

Detailed Description

Reads *.graphqls files from modules and combines the results as array to be used with a library to configure objects

Definition at line 17 of file GraphQlReader.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( FileResolverInterface  $fileResolver,
TypeReaderComposite  $typeReader,
  $fileName = self::GRAPHQL_SCHEMA_FILE,
  $defaultScope = 'global' 
)
Parameters
FileResolverInterface$fileResolver
TypeReaderComposite$typeReader
string$fileName
string$defaultScope

Definition at line 51 of file GraphQlReader.php.

56  {
57  $this->fileResolver = $fileResolver;
58  $this->typeReader = $typeReader;
59  $this->defaultScope = $defaultScope;
60  $this->fileName = $fileName;
61  }

Member Function Documentation

◆ read()

read (   $scope = null)

{Read configuration scope

Parameters
string | null$scope
Returns
array
}

Compatible with

See also
GraphQlReader::parseTypes

Implements ReaderInterface.

Definition at line 66 of file GraphQlReader.php.

66  : array
67  {
68  $results = [];
69  $scope = $scope ?: $this->defaultScope;
70  $schemaFiles = $this->fileResolver->get($this->fileName, $scope);
71  if (!count($schemaFiles)) {
72  return $results;
73  }
74 
78  $knownTypes = [];
79  foreach ($schemaFiles as $partialSchemaContent) {
80  $partialSchemaTypes = $this->parseTypes($partialSchemaContent);
81 
82  // Keep declarations from current partial schema, add missing declarations from all previously read schemas
83  $knownTypes = $partialSchemaTypes + $knownTypes;
84  $schemaContent = implode("\n", $knownTypes);
85 
86  $partialResults = $this->readPartialTypes($schemaContent);
87 
88  $results = array_replace_recursive($results, $partialResults);
89  }
90 
91  $results = $this->copyInterfaceFieldsToConcreteTypes($results);
92  return $results;
93  }
$results
Definition: popup.phtml:13

Field Documentation

◆ GRAPHQL_PLACEHOLDER_FIELD_NAME

const GRAPHQL_PLACEHOLDER_FIELD_NAME = 'placeholder_graphql_field'

Definition at line 19 of file GraphQlReader.php.

◆ GRAPHQL_SCHEMA_FILE

const GRAPHQL_SCHEMA_FILE = 'schema.graphqls'

Definition at line 21 of file GraphQlReader.php.


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