private function analyzeSelectionSet(SelectionSetNode $selectionSet, ObjectType $parentType) : array
    {
        $fields = [];
        foreach ($selectionSet->selections as $selectionNode) {
            if ($selectionNode instanceof FieldNode) {
                $fieldName     = $selectionNode->name->value;
                $type          = $parentType->getField($fieldName);
                $selectionType = $type->getType();

                $subfields = [];
                if ($selectionNode->selectionSet) {
                    $subfields = $this->analyzeSubFields($selectionType, $selectionNode->selectionSet);
                }

                $fields[$fieldName] = [
                    'type' => $selectionType,
                    'fields' => $subfields ?? [],
                    'args' => Values::getArgumentValues($type, $selectionNode, $this->variableValues),
                ];
            } elseif ($selectionNode instanceof FragmentSpreadNode) {
                $spreadName = $selectionNode->name->value;
                if (isset($this->fragments[$spreadName])) {
                    $fragment  = $this->fragments[$spreadName];
                    $type      = $this->schema->getType($fragment->typeCondition->name->value);
                    $subfields = $this->analyzeSubFields($type, $fragment->selectionSet);

                    $fields = $this->arrayMergeDeep(
                        $subfields,
                        $fields
                    );
                }
            } elseif ($selectionNode instanceof InlineFragmentNode) {
                $type      = $this->schema->getType($selectionNode->typeCondition->name->value);
                $subfields = $this->analyzeSubFields($type, $selectionNode->selectionSet);

                $fields = $this->arrayMergeDeep(
                    $subfields,
                    $fields
                );
            }
        }

        return $fields;
    }
private function analyzeSelectionSet(SelectionSetNode $selectionSet, ObjectType $parentType) : array
    {
        $fields = [];
        foreach ($selectionSet->selections as $selectionNode) {
            if ($selectionNode instanceof FieldNode) {
                $fieldName     = $selectionNode->name->value;
                $type          = $parentType->getField($fieldName);
                $selectionType = $type->getType();

                $subfields = [];
                if ($selectionNode->selectionSet) {
                    $subfields = $this->analyzeSubFields($selectionType, $selectionNode->selectionSet);
                }

                $fields[$fieldName] = [
                    'type' => $selectionType,
                    'fields' => $subfields ?? [],
                    'args' => Values::getArgumentValues($type, $selectionNode, $this->variableValues),
                ];
            } elseif ($selectionNode instanceof FragmentSpreadNode) {
                $spreadName = $selectionNode->name->value;
                if (isset($this->fragments[$spreadName])) {
                    $fragment  = $this->fragments[$spreadName];
                    $type      = $this->schema->getType($fragment->typeCondition->name->value);
                    $subfields = $this->analyzeSubFields($type, $fragment->selectionSet);

                    $fields = $this->arrayMergeDeep(
                        $subfields,
                        $fields
                    );
                }
            } elseif ($selectionNode instanceof InlineFragmentNode) {
                $type      = $this->schema->getType($selectionNode->typeCondition->name->value);
                $subfields = $this->analyzeSubFields($type, $selectionNode->selectionSet);

                $fields = $this->arrayMergeDeep(
                    $subfields,
                    $fields
                );
            }
        }

        return $fields;
    }
private function analyzeSelectionSet ( SelectionSetNode $ selectionSet , ObjectType $ parentType ) : array { $ fields = [ ] ; foreach ( $ selectionSet -> selections as $ selectionNode ) { if ( $ selectionNode instanceof FieldNode ) { $ fieldName = $ selectionNode -> name -> value ; $ type = $ parentType -> getField ( $ fieldName ) ; $ selectionType = $ type -> getType ( ) ; $ subfields = [ ] ; if ( $ selectionNode -> selectionSet ) { $ subfields = $ this -> analyzeSubFields ( $ selectionType , $ selectionNode -> selectionSet ) ; } $ fields [ $ fieldName ] = [ 'type' => $ selectionType , 'fields' => $ subfields ?? [ ] , 'args' => Values :: getArgumentValues ( $ type , $ selectionNode , $ this -> variableValues ) , ] ; } elseif ( $ selectionNode instanceof FragmentSpreadNode ) { $ spreadName = $ selectionNode -> name -> value ; if ( isset ( $ this -> fragments [ $ spreadName ] ) ) { $ fragment = $ this -> fragments [ $ spreadName ] ; $ type = $ this -> schema -> getType ( $ fragment -> typeCondition -> name -> value ) ; $ subfields = $ this -> analyzeSubFields ( $ type , $ fragment -> selectionSet ) ; $ fields = $ this -> arrayMergeDeep ( $ subfields , $ fields ) ; } } elseif ( $ selectionNode instanceof InlineFragmentNode ) { $ type = $ this -> schema -> getType ( $ selectionNode -> typeCondition -> name -> value ) ; $ subfields = $ this -> analyzeSubFields ( $ type , $ selectionNode -> selectionSet ) ; $ fields = $ this -> arrayMergeDeep ( $ subfields , $ fields ) ; } } return $ fields ; }
@return mixed[]

@throws Error
@return mixed []