mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-24 22:06:04 +03:00
Rename parameters and private fields to match what they contain
This commit is contained in:
parent
93ccd7351d
commit
bc66034f40
@ -9,7 +9,7 @@
|
|||||||
"API"
|
"API"
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.1||^8.0",
|
"php": "^7.1",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"ext-mbstring": "*"
|
"ext-mbstring": "*"
|
||||||
},
|
},
|
||||||
|
@ -45,7 +45,7 @@ class ExecutionContext
|
|||||||
public $errors;
|
public $errors;
|
||||||
|
|
||||||
/** @var PromiseAdapter */
|
/** @var PromiseAdapter */
|
||||||
public $promises;
|
public $promiseAdapter;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
$schema,
|
$schema,
|
||||||
@ -53,7 +53,7 @@ class ExecutionContext
|
|||||||
$root,
|
$root,
|
||||||
$contextValue,
|
$contextValue,
|
||||||
$operation,
|
$operation,
|
||||||
$variables,
|
$variableValues,
|
||||||
$errors,
|
$errors,
|
||||||
$fieldResolver,
|
$fieldResolver,
|
||||||
$promiseAdapter
|
$promiseAdapter
|
||||||
@ -63,10 +63,10 @@ class ExecutionContext
|
|||||||
$this->rootValue = $root;
|
$this->rootValue = $root;
|
||||||
$this->contextValue = $contextValue;
|
$this->contextValue = $contextValue;
|
||||||
$this->operation = $operation;
|
$this->operation = $operation;
|
||||||
$this->variableValues = $variables;
|
$this->variableValues = $variableValues;
|
||||||
$this->errors = $errors ?: [];
|
$this->errors = $errors ?: [];
|
||||||
$this->fieldResolver = $fieldResolver;
|
$this->fieldResolver = $fieldResolver;
|
||||||
$this->promises = $promiseAdapter;
|
$this->promiseAdapter = $promiseAdapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addError(Error $error)
|
public function addError(Error $error)
|
||||||
|
@ -212,7 +212,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
// But for the "sync" case it is always fulfilled
|
// But for the "sync" case it is always fulfilled
|
||||||
return $this->isPromise($result)
|
return $this->isPromise($result)
|
||||||
? $result
|
? $result
|
||||||
: $this->exeContext->promises->createFulfilled($result);
|
: $this->exeContext->promiseAdapter->createFulfilled($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -262,7 +262,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
if ($error instanceof Error) {
|
if ($error instanceof Error) {
|
||||||
$this->exeContext->addError($error);
|
$this->exeContext->addError($error);
|
||||||
|
|
||||||
return $this->exeContext->promises->createFulfilled(null);
|
return $this->exeContext->promiseAdapter->createFulfilled(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -574,6 +574,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This method looks up the field on the given type definition.
|
* This method looks up the field on the given type definition.
|
||||||
|
*
|
||||||
* It has special casing for the two introspection fields, __schema
|
* It has special casing for the two introspection fields, __schema
|
||||||
* and __typename. __typename is special because it can always be
|
* and __typename. __typename is special because it can always be
|
||||||
* queried as a field, even in situations where no other fields
|
* queried as a field, even in situations where no other fields
|
||||||
@ -608,8 +609,8 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
|
* Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField` function.
|
||||||
* function. Returns the result of resolveFn or the abrupt-return Error object.
|
* Returns the result of resolveFn or the abrupt-return Error object.
|
||||||
*
|
*
|
||||||
* @param FieldDefinition $fieldDef
|
* @param FieldDefinition $fieldDef
|
||||||
* @param FieldNode $fieldNode
|
* @param FieldNode $fieldNode
|
||||||
@ -623,7 +624,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
private function resolveOrError($fieldDef, $fieldNode, $resolveFn, $source, $context, $info)
|
private function resolveOrError($fieldDef, $fieldNode, $resolveFn, $source, $context, $info)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Build hash of arguments from the field.arguments AST, using the
|
// Build a map of arguments from the field.arguments AST, using the
|
||||||
// variables scope to fulfill any variable references.
|
// variables scope to fulfill any variable references.
|
||||||
$args = Values::getArgumentValues(
|
$args = Values::getArgumentValues(
|
||||||
$fieldDef,
|
$fieldDef,
|
||||||
@ -685,7 +686,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
function ($error) use ($exeContext) {
|
function ($error) use ($exeContext) {
|
||||||
$exeContext->addError($error);
|
$exeContext->addError($error);
|
||||||
|
|
||||||
return $this->exeContext->promises->createFulfilled(null);
|
return $this->exeContext->promiseAdapter->createFulfilled(null);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -732,7 +733,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
return $promise->then(
|
return $promise->then(
|
||||||
null,
|
null,
|
||||||
function ($error) use ($fieldNodes, $path) {
|
function ($error) use ($fieldNodes, $path) {
|
||||||
return $this->exeContext->promises->createRejected(Error::createLocatedError(
|
return $this->exeContext->promiseAdapter->createRejected(Error::createLocatedError(
|
||||||
$error,
|
$error,
|
||||||
$fieldNodes,
|
$fieldNodes,
|
||||||
$path
|
$path
|
||||||
@ -864,7 +865,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
*/
|
*/
|
||||||
private function isPromise($value)
|
private function isPromise($value)
|
||||||
{
|
{
|
||||||
return $value instanceof Promise || $this->exeContext->promises->isThenable($value);
|
return $value instanceof Promise || $this->exeContext->promiseAdapter->isThenable($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -880,12 +881,12 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
if ($value === null || $value instanceof Promise) {
|
if ($value === null || $value instanceof Promise) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
if ($this->exeContext->promises->isThenable($value)) {
|
if ($this->exeContext->promiseAdapter->isThenable($value)) {
|
||||||
$promise = $this->exeContext->promises->convertThenable($value);
|
$promise = $this->exeContext->promiseAdapter->convertThenable($value);
|
||||||
if (! $promise instanceof Promise) {
|
if (! $promise instanceof Promise) {
|
||||||
throw new InvariantViolation(sprintf(
|
throw new InvariantViolation(sprintf(
|
||||||
'%s::convertThenable is expected to return instance of GraphQL\Executor\Promise\Promise, got: %s',
|
'%s::convertThenable is expected to return instance of GraphQL\Executor\Promise\Promise, got: %s',
|
||||||
get_class($this->exeContext->promises),
|
get_class($this->exeContext->promiseAdapter),
|
||||||
Utils::printSafe($promise)
|
Utils::printSafe($promise)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@ -927,28 +928,27 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Complete a list value by completing each item in the list with the
|
* Complete a list value by completing each item in the list with the inner type.
|
||||||
* inner type
|
|
||||||
*
|
*
|
||||||
* @param FieldNode[] $fieldNodes
|
* @param FieldNode[] $fieldNodes
|
||||||
* @param mixed[] $path
|
* @param mixed[] $path
|
||||||
* @param mixed $result
|
* @param mixed[]|Traversable &$results
|
||||||
*
|
*
|
||||||
* @return mixed[]|Promise
|
* @return mixed[]|Promise
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
private function completeListValue(ListOfType $returnType, $fieldNodes, ResolveInfo $info, $path, &$result)
|
private function completeListValue(ListOfType $returnType, $fieldNodes, ResolveInfo $info, $path, &$results)
|
||||||
{
|
{
|
||||||
$itemType = $returnType->getWrappedType();
|
$itemType = $returnType->getWrappedType();
|
||||||
Utils::invariant(
|
Utils::invariant(
|
||||||
is_array($result) || $result instanceof Traversable,
|
is_array($results) || $results instanceof Traversable,
|
||||||
'User Error: expected iterable, but did not find one for field ' . $info->parentType . '.' . $info->fieldName . '.'
|
'User Error: expected iterable, but did not find one for field ' . $info->parentType . '.' . $info->fieldName . '.'
|
||||||
);
|
);
|
||||||
$containsPromise = false;
|
$containsPromise = false;
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$completedItems = [];
|
$completedItems = [];
|
||||||
foreach ($result as $item) {
|
foreach ($results as $item) {
|
||||||
$fieldPath = $path;
|
$fieldPath = $path;
|
||||||
$fieldPath[] = $i++;
|
$fieldPath[] = $i++;
|
||||||
$info->path = $fieldPath;
|
$info->path = $fieldPath;
|
||||||
@ -959,7 +959,9 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
$completedItems[] = $completedItem;
|
$completedItems[] = $completedItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $containsPromise ? $this->exeContext->promises->all($completedItems) : $completedItems;
|
return $containsPromise
|
||||||
|
? $this->exeContext->promiseAdapter->all($completedItems)
|
||||||
|
: $completedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1101,7 +1103,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (! empty($promisedIsTypeOfResults)) {
|
if (! empty($promisedIsTypeOfResults)) {
|
||||||
return $this->exeContext->promises->all($promisedIsTypeOfResults)
|
return $this->exeContext->promiseAdapter->all($promisedIsTypeOfResults)
|
||||||
->then(static function ($isTypeOfResults) use ($possibleTypes) {
|
->then(static function ($isTypeOfResults) use ($possibleTypes) {
|
||||||
foreach ($isTypeOfResults as $index => $result) {
|
foreach ($isTypeOfResults as $index => $result) {
|
||||||
if ($result) {
|
if ($result) {
|
||||||
@ -1187,7 +1189,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
/**
|
/**
|
||||||
* @param FieldNode[] $fieldNodes
|
* @param FieldNode[] $fieldNodes
|
||||||
* @param mixed[] $path
|
* @param mixed[] $path
|
||||||
* @param mixed[] $result
|
* @param mixed $result
|
||||||
*
|
*
|
||||||
* @return mixed[]|Promise|stdClass
|
* @return mixed[]|Promise|stdClass
|
||||||
*
|
*
|
||||||
@ -1299,7 +1301,7 @@ class ReferenceExecutor implements ExecutorImplementation
|
|||||||
{
|
{
|
||||||
$keys = array_keys($assoc);
|
$keys = array_keys($assoc);
|
||||||
$valuesAndPromises = array_values($assoc);
|
$valuesAndPromises = array_values($assoc);
|
||||||
$promise = $this->exeContext->promises->all($valuesAndPromises);
|
$promise = $this->exeContext->promiseAdapter->all($valuesAndPromises);
|
||||||
|
|
||||||
return $promise->then(static function ($values) use ($keys) {
|
return $promise->then(static function ($values) use ($keys) {
|
||||||
$resolvedResults = [];
|
$resolvedResults = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user