Version 4.7.6
This commit is contained in:
1 parent
8ba7d43898
commit
7b7404e741
1085 files changed
+30590
-7837
No files matched your search
+31
@@ -584,6 +584,8 @@ class AST
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use getOperationAST instead.
|
||||
*
|
||||
* Returns operation type ("query", "mutation" or "subscription") given a document and operation name
|
||||
*
|
||||
* @param string $operationName
|
||||
@@ -608,4 +610,33 @@ class AST
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the operation within a document by name.
|
||||
*
|
||||
* If a name is not provided, an operation is only returned if the document has exactly one.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public static function getOperationAST(DocumentNode $document, ?string $operationName = null) : ?OperationDefinitionNode
|
||||
{
|
||||
$operation = null;
|
||||
foreach ($document->definitions->getIterator() as $node) {
|
||||
if (! $node instanceof OperationDefinitionNode) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($operationName === null) {
|
||||
// We found a second operation, so we bail instead of returning an ambiguous result.
|
||||
if ($operation !== null) {
|
||||
return null;
|
||||
}
|
||||
$operation = $node;
|
||||
} elseif ($node->name instanceof NameNode && $node->name->value === $operationName) {
|
||||
return $node;
|
||||
}
|
||||
}
|
||||
|
||||
return $operation;
|
||||
}
|
||||
}
|
||||
@@ -489,7 +489,7 @@ class BuildClientSchema
|
||||
'name' => $directive['name'],
|
||||
'description' => $directive['description'],
|
||||
'args' => $this->buildInputValueDefMap($directive['args']),
|
||||
'isRepeatable' => $directive['isRepeatable'],
|
||||
'isRepeatable' => $directive['isRepeatable'] ?? false,
|
||||
'locations' => $directive['locations'],
|
||||
]);
|
||||
}
|
||||
|
||||
+5
-7
@@ -7,6 +7,7 @@ namespace GraphQL\Utils;
|
||||
use ArrayAccess;
|
||||
use GraphQL\Type\Definition\EnumValueDefinition;
|
||||
use InvalidArgumentException;
|
||||
use ReturnTypeWillChange;
|
||||
use SplObjectStorage;
|
||||
use function array_key_exists;
|
||||
use function array_search;
|
||||
@@ -90,7 +91,7 @@ class MixedStore implements ArrayAccess
|
||||
* <p>
|
||||
* The return value will be casted to boolean if non-boolean was returned.
|
||||
*/
|
||||
public function offsetExists($offset)
|
||||
public function offsetExists($offset) : bool
|
||||
{
|
||||
if ($offset === false) {
|
||||
return $this->falseValueIsSet;
|
||||
@@ -135,6 +136,7 @@ class MixedStore implements ArrayAccess
|
||||
*
|
||||
* @return mixed Can return all value types.
|
||||
*/
|
||||
#[ReturnTypeWillChange]
|
||||
public function offsetGet($offset)
|
||||
{
|
||||
if ($offset === true) {
|
||||
@@ -181,10 +183,8 @@ class MixedStore implements ArrayAccess
|
||||
* @param mixed $value <p>
|
||||
* The value to set.
|
||||
* </p>
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetSet($offset, $value)
|
||||
public function offsetSet($offset, $value) : void
|
||||
{
|
||||
if ($offset === false) {
|
||||
$this->falseValue = $value;
|
||||
@@ -217,10 +217,8 @@ class MixedStore implements ArrayAccess
|
||||
* @param mixed $offset <p>
|
||||
* The offset to unset.
|
||||
* </p>
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetUnset($offset)
|
||||
public function offsetUnset($offset) : void
|
||||
{
|
||||
if ($offset === true) {
|
||||
$this->trueValue = null;
|
||||
|
||||
+9
-3
@@ -494,14 +494,19 @@ class SchemaExtender
|
||||
'locations' => $directive->locations,
|
||||
'args' => static::extendArgs($directive->args),
|
||||
'astNode' => $directive->astNode,
|
||||
'isRepeatable' => $directive->isRepeatable,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, bool> $options
|
||||
*/
|
||||
public static function extend(Schema $schema, DocumentNode $documentAST, array $options = []) : Schema
|
||||
{
|
||||
public static function extend(
|
||||
Schema $schema,
|
||||
DocumentNode $documentAST,
|
||||
array $options = [],
|
||||
?callable $typeConfigDecorator = null
|
||||
) : Schema {
|
||||
if (! (isset($options['assumeValid']) || isset($options['assumeValidSDL']))) {
|
||||
DocumentValidator::assertValidSDLExtension($documentAST, $schema);
|
||||
}
|
||||
@@ -579,7 +584,8 @@ class SchemaExtender
|
||||
}
|
||||
|
||||
throw new Error('Unknown type: "' . $typeName . '". Ensure that this type exists either in the original schema, or is added in a type definition.', [$typeName]);
|
||||
}
|
||||
},
|
||||
$typeConfigDecorator
|
||||
);
|
||||
|
||||
static::$extendTypeCache = [];
|
||||
|
||||
+10
-8
@@ -25,6 +25,7 @@ use GraphQL\Type\Definition\Directive;
|
||||
use GraphQL\Type\Definition\EnumType;
|
||||
use GraphQL\Type\Definition\FieldArgument;
|
||||
use GraphQL\Type\Definition\FieldDefinition;
|
||||
use GraphQL\Type\Definition\HasFieldsType;
|
||||
use GraphQL\Type\Definition\ImplementingType;
|
||||
use GraphQL\Type\Definition\InputObjectType;
|
||||
use GraphQL\Type\Definition\InputType;
|
||||
@@ -196,9 +197,10 @@ class TypeInfo
|
||||
if ($type instanceof ImplementingType) {
|
||||
$nestedTypes = array_merge($nestedTypes, $type->getInterfaces());
|
||||
}
|
||||
if ($type instanceof ObjectType || $type instanceof InterfaceType) {
|
||||
foreach ($type->getFields() as $fieldName => $field) {
|
||||
if (count($field->args ?? []) > 0) {
|
||||
|
||||
if ($type instanceof HasFieldsType) {
|
||||
foreach ($type->getFields() as $field) {
|
||||
if (count($field->args) > 0) {
|
||||
$fieldArgTypes = array_map(
|
||||
static function (FieldArgument $arg) : Type {
|
||||
return $arg->getType();
|
||||
@@ -212,7 +214,7 @@ class TypeInfo
|
||||
}
|
||||
}
|
||||
if ($type instanceof InputObjectType) {
|
||||
foreach ($type->getFields() as $fieldName => $field) {
|
||||
foreach ($type->getFields() as $field) {
|
||||
$nestedTypes[] = $field->getType();
|
||||
}
|
||||
}
|
||||
@@ -414,11 +416,11 @@ class TypeInfo
|
||||
if ($name === $typeNameMeta->name && $parentType instanceof CompositeType) {
|
||||
return $typeNameMeta;
|
||||
}
|
||||
if ($parentType instanceof ObjectType ||
|
||||
$parentType instanceof InterfaceType) {
|
||||
$fields = $parentType->getFields();
|
||||
|
||||
return $fields[$name] ?? null;
|
||||
if ($parentType instanceof ObjectType ||
|
||||
$parentType instanceof InterfaceType
|
||||
) {
|
||||
return $parentType->findField($name);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user