src/Executor/ReferenceExecutor.php
private function executeFieldsSerially(ObjectType $parentType, $sourceValue, $path, $fields)
    {
        $result = $this->promiseReduce(
            array_keys($fields->getArrayCopy()),
            function ($results, $responseName) use ($path, $parentType, $sourceValue, $fields) {
                $fieldNodes  = $fields[$responseName];
                $fieldPath   = $path;
                $fieldPath[] = $responseName;
                $result      = $this->resolveField($parentType, $sourceValue, $fieldNodes, $fieldPath);
                if ($result === self::$UNDEFINED) {
                    return $results;
                }
                $promise = $this->getPromise($result);
                if ($promise) {
                    return $promise->then(static function ($resolvedResult) use ($responseName, $results) {
                        $results[$responseName] = $resolvedResult;

                        return $results;
                    });
                }
                $results[$responseName] = $result;

                return $results;
            },
            []
        );
        if ($this->isPromise($result)) {
            return $result->then(static function ($resolvedResults) {
                return self::fixResultsIfEmptyArray($resolvedResults);
            });
        }

        return self::fixResultsIfEmptyArray($result);
    }
private function executeFieldsSerially(ObjectType $parentType, $sourceValue, $path, $fields)
    {
        $result = $this->promiseReduce(
            array_keys($fields->getArrayCopy()),
            function ($results, $responseName) use ($path, $parentType, $sourceValue, $fields) {
                $fieldNodes  = $fields[$responseName];
                $fieldPath   = $path;
                $fieldPath[] = $responseName;
                $result      = $this->resolveField($parentType, $sourceValue, $fieldNodes, $fieldPath);
                if ($result === self::$UNDEFINED) {
                    return $results;
                }
                $promise = $this->getPromise($result);
                if ($promise) {
                    return $promise->then(static function ($resolvedResult) use ($responseName, $results) {
                        $results[$responseName] = $resolvedResult;

                        return $results;
                    });
                }
                $results[$responseName] = $result;

                return $results;
            },
            []
        );
        if ($this->isPromise($result)) {
            return $result->then(static function ($resolvedResults) {
                return self::fixResultsIfEmptyArray($resolvedResults);
            });
        }

        return self::fixResultsIfEmptyArray($result);
    }
private function executeFieldsSerially ( ObjectType $ parentType , $ sourceValue , $ path , $ fields ) { $ result = $ this -> promiseReduce ( array_keys ( $ fields -> getArrayCopy ( ) ) , function ( $ results , $ responseName ) use ( $ path , $ parentType , $ sourceValue , $ fields ) { $ fieldNodes = $ fields [ $ responseName ] ; $ fieldPath = $ path ; $ fieldPath [ ] = $ responseName ; $ result = $ this -> resolveField ( $ parentType , $ sourceValue , $ fieldNodes , $ fieldPath ) ; if ( $ result === self :: $ UNDEFINED ) { return $ results ; } $ promise = $ this -> getPromise ( $ result ) ; if ( $ promise ) { return $ promise -> then ( static function ( $ resolvedResult ) use ( $ responseName , $ results ) { $ results [ $ responseName ] = $ resolvedResult ; return $ results ; } ) ; } $ results [ $ responseName ] = $ result ; return $ results ; } , [ ] ) ; if ( $ this -> isPromise ( $ result ) ) { return $ result -> then ( static function ( $ resolvedResults ) { return self :: fixResultsIfEmptyArray ( $ resolvedResults ) ; } ) ; } return self :: fixResultsIfEmptyArray ( $ result ) ; }
Implements the "Evaluating selection sets" section of the spec
for "write" mode.

@param mixed[]     $sourceValue
@param mixed[]     $path
@param ArrayObject $fields

@return Promise|stdClass|mixed[]
Implements the Evaluating selection sets section of the spec for write mode .