Parse defined types from a schema into an array with the native GraphQL Scalar types for each field

@param Schema $schema
@param array $definitionFileDirectories
@return Type[]
494581
private function getDefinedTypesFromSchema(Schema $schema, array $definitionFileDirectories): array
    {
        $definedTypes = $this->definitionsParser->getGraphqlDefinitionFilePaths(
            $definitionFileDirectories['types']
        );

        foreach ($definedTypes as $key => $type) {
            $definedTypes[$key] = str_replace('.graphql', '', basename($type));
        }

        $internalTypes = [];
        /**
         * @var string $typeName
         * @var ObjectType $type
         */
        foreach ($schema->getTypeMap() as $typeName => $type) {
            if (! in_array($typeName, $definedTypes) || ! method_exists($type, 'getFields')) {
                continue;
            }

            /**
             * @var string $fieldName
             * @var FieldDefinition $fieldType
             */
            foreach ($type->getFields() as $fieldName => $fieldType) {
                $graphQLType = $fieldType->getType();

                //Every required field is defined by a parent 'NonNullType'
                if (method_exists($graphQLType, 'getWrappedType')) {
                    // Clone the field to prevent pass by reference,
                    // because we want to add a config value unique to this field.
                    $graphQLType = clone $graphQLType->getWrappedType();

                    //We want to know later on wether or not a field is required
                    $graphQLType->config['generator-required'] = true;
                }

                if (! in_array(get_class($graphQLType), $this->supportedGraphQLTypes)) {
                    continue;
                };

                // This retrieves the GraphQL type for this field from the webonyx/graphql-php package
                $internalTypes[$typeName][$fieldName] = $graphQLType;
            }
        }

        return $internalTypes;
    }
587309
public function insert(Schema $schema): Schema
    {
        $this->schemas[$schema->getNamespace()] = $schema;
        return $schema;
    }
522169
def parse_schema_definition(lexer: Lexer) -> Node:
    """"""
    start = lexer.token
    expect_keyword(lexer, "schema")
    directives = parse_directives(lexer, True)
    operation_types = many_nodes(
        lexer, TokenKind.BRACE_L, parse_operation_type_definition, TokenKind.BRACE_R
    )
    return Node(
        directives=directives, operation_types=operation_types, loc=loc(lexer, start)
    )
81625
private function getExtendsSchemas(SchemaDescriptor $schema)
    {
        $schemaIds = [];

        $check = $schema->getExtends();
        while ($check) {
            $schemaIds[] = $check->getId()->getCurieWithMajorRev();

            $check = $check->getExtends();
        }

        return $schemaIds;
    }
1224581
public function visitSchema(Schema $schema)
    {
        $result = $this->result($schema);
        if (null !== $result) {
            return $result;
        }

        $result = $this->register($schema, $this->createResult());

        foreach ($schema->constraints() as $constraint) {
            $result = $result->merge($constraint->accept($this));
        }

        if ($result->isValid()) {
            $result->addMatch($this->createMatch($schema));
        }

        return $result;
    }
452522
public function visitSchema(Schema $schema)
    {
        return new Schema(
            $this->transformConstraintArray($schema->constraints()),
            $schema->defaultValue(),
            $schema->title(),
            $schema->description()
        );
    }
45135
protected function getSelectedQueryAttributes(array $attributes, LdapObjectSchema $schema = null)
    {
        // Interpret a single wildcard as only schema attributes.
        if ($schema && !empty($attributes) && $attributes[0] == '*') {
            $attributes = array_keys($schema->getAttributeMap());
        // Interpret a double wildcard as all LDAP attributes even if they aren't in the schema file.
        } elseif ($schema && !empty($attributes) && $attributes[0] == '**') {
            $attributes = ['*'];
        }

        return $attributes;
    }
890493
private function validateFilesPaths(array $definitionFileDirectories): bool
    {
        if (count($definitionFileDirectories) < 1) {
            throw new InvalidConfigurationException(
                'The "schema_paths" config value is empty, it should contain a value with a valid path for the following keys: mutations, queries, types'
            );
        }

        if (array_diff(array_keys($definitionFileDirectories), $this->requiredSchemaFileKeys)) {
            throw new InvalidConfigurationException(
                'The "schema_paths" config value is incomplete, it should contain a value with a valid path for the following keys: mutations, queries, types'
            );
        }
        foreach ($definitionFileDirectories as $key => $path) {
            if (empty($path)) {
                throw new InvalidConfigurationException(
                    sprintf(
                        'The "schema_paths" config value for key "%s" is empty, it should contain a value with a valid path',
                        $key
                    )
                );
            }

            if (! file_exists($path)) {
                throw new InvalidConfigurationException(
                    sprintf('The "schema_paths" config value for key "%s" contains a path that does not exist', $key)
                );
            }
        }

        return true;
    }
260058
protected function addVirtualFieldsToSchema(array $schema, string $module): array
    {
        if (isset($schema['definitions']['virtualFieldName'])) {
            $virtualFields = Utility::getVirtualModuleFields($module, false);
            if (!empty($virtualFields)) {
                $schema['definitions']['virtualFieldName']['enum'] = array_keys($virtualFields);
            }
        }

        return $schema;
    }
259878
protected function result(Schema $schema)
    {
        $key = $this->generateVisitKey($schema);
        if (array_key_exists($key, $this->results)) {
            return $this->results[$key];
        }

        return null;
    }
114115
protected function generateProperties(array $schema)
    {
        $directory = $this->getMappingDirectory('Property');
        $this->generateAbstractProperty($directory);
        foreach ($schema['properties'] as $property => $data) {
            $this->generateProperty($property, $data, $directory, $schema['datatypes']);
        }
    }
1365299
protected function getSchemaFileName($folder, $schema)
    {
        $file = null;

        foreach (['yml', 'yaml'] as $ext) {
            $fileCheck = $folder.'/'.$schema.'.'.$ext;
            if (is_readable($fileCheck)) {
                $file = $fileCheck;
                break;
            }
        }

        if (is_null($file)) {
            throw new SchemaParserException(sprintf('Cannot find schema for "%s" in "%s"', $schema, $folder));
        }

        return $file;
    }
858061
protected function getModuleSchemaPaths(array $modulePaths): array
    {
        $schemaPaths = [];

        $fileFinder = $this->createFinder()->in($modulePaths)->name('*.schema.xml');

        /*** @var \Symfony\Component\Finder\SplFileInfo[] $files */
        $files = $fileFinder->files();

        foreach ($files as $file) {
            $schemaPaths[] = $file->getRealPath();
        }

        return $schemaPaths;
    }
1243
public function findBy(string $schema, string $typeName, array $criteria = []) : array
    {
        if (!$this->typeExists($schema, $typeName)) {
            return [];
        }

        foreach ($this->storage[$schema][$typeName] as $id => $data) {
            if ($this->matchesCriteria($criteria, $data)) {
                return $data;
            }
        }

        return [];
    }
991149
public function getSchemaTables(Schema $schema)
    {
        $tables = [];

        foreach ($this->tables->keys() as $name) {
            /** @var BaseTable $table */
            $table = $this->tables[$name];
            $tables[$name] = $table->buildTable($schema, $name, $this->charset, $this->collate);
        }

        foreach ($this->tableGenerators as $generator) {
            $table = $generator($schema);

            if (is_array($table)) {
                /** @var Table[] $table */
                foreach ($table as $t) {
                    $alias = str_replace($this->prefix, '', $t->getName());
                    $t->addOption('alias', $alias);
                    $t->addOption('charset', $this->charset);
                    $t->addOption('collate', $this->collate);
                    $tables[$alias] = $t;
                }
            } else {
                /** @var Table $table */
                $alias = str_replace($this->prefix, '', $table->getName());
                $table->addOption('alias', $alias);
                $table->addOption('charset', $this->charset);
                $table->addOption('collate', $this->collate);
                $tables[$alias] = $table;
            }
        }

        return $tables;
    }
596747
private static function parseDefinitions(array $definitions): array
    {
        if (\count($definitions) === 0) {
            return $definitions;
        }

        return \array_map(
            function ($definition) {
                if (\is_array($definition)) {
                    return $definition;
                }

                return self::loadDefinitionsFromPath($definition);
            },
            $definitions
        );
    }
133360
public function getQueryMapping($schemaKey = 'default')
    {
        /** @noinspection PhpUndefinedFieldInspection */
        /** @noinspection StaticInvocationViaThisInspection */
        $pathWithKey = $this->getSchemaMapping();
        if (!isset($pathWithKey[$schemaKey])) {
            return [];
        }

        $path = trim($pathWithKey[$schemaKey]);
        $contents = trim(file_get_contents($path));
        $result = json_decode($contents, true);
        if (!is_array($result)) {
            return [];
        }

        return $result;
    }