mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-21 20:36:05 +03:00
AST: Replaced array with NodeList where missing
This commit is contained in:
parent
d1d4455eaa
commit
261f8f5ebd
@ -183,7 +183,7 @@ class AST
|
||||
$valuesNodes[] = $itemNode;
|
||||
}
|
||||
|
||||
return new ListValueNode(['values' => $valuesNodes]);
|
||||
return new ListValueNode(['values' => new NodeList($valuesNodes)]);
|
||||
}
|
||||
|
||||
return self::astFromValue($value, $itemType);
|
||||
@ -235,7 +235,7 @@ class AST
|
||||
]);
|
||||
}
|
||||
|
||||
return new ObjectValueNode(['fields' => $fieldNodes]);
|
||||
return new ObjectValueNode(['fields' => new NodeList($fieldNodes)]);
|
||||
}
|
||||
|
||||
if ($type instanceof ScalarType || $type instanceof EnumType) {
|
||||
|
@ -10,6 +10,7 @@ use GraphQL\Language\AST\FloatValueNode;
|
||||
use GraphQL\Language\AST\IntValueNode;
|
||||
use GraphQL\Language\AST\ListValueNode;
|
||||
use GraphQL\Language\AST\NameNode;
|
||||
use GraphQL\Language\AST\NodeList;
|
||||
use GraphQL\Language\AST\NullValueNode;
|
||||
use GraphQL\Language\AST\ObjectFieldNode;
|
||||
use GraphQL\Language\AST\ObjectValueNode;
|
||||
@ -179,18 +180,18 @@ class AstFromValueTest extends TestCase
|
||||
public function testConvertsArrayValuesToListASTs() : void
|
||||
{
|
||||
$value1 = new ListValueNode([
|
||||
'values' => [
|
||||
'values' => new NodeList([
|
||||
new StringValueNode(['value' => 'FOO']),
|
||||
new StringValueNode(['value' => 'BAR']),
|
||||
],
|
||||
]),
|
||||
]);
|
||||
self::assertEquals($value1, AST::astFromValue(['FOO', 'BAR'], Type::listOf(Type::string())));
|
||||
|
||||
$value2 = new ListValueNode([
|
||||
'values' => [
|
||||
'values' => new NodeList([
|
||||
new EnumValueNode(['value' => 'HELLO']),
|
||||
new EnumValueNode(['value' => 'GOODBYE']),
|
||||
],
|
||||
]),
|
||||
]);
|
||||
self::assertEquals($value2, AST::astFromValue(['HELLO', 'GOODBYE'], Type::listOf($this->myEnum())));
|
||||
}
|
||||
@ -220,10 +221,10 @@ class AstFromValueTest extends TestCase
|
||||
]);
|
||||
|
||||
$expected = new ObjectValueNode([
|
||||
'fields' => [
|
||||
'fields' => new NodeList([
|
||||
$this->objectField('foo', new IntValueNode(['value' => '3'])),
|
||||
$this->objectField('bar', new EnumValueNode(['value' => 'HELLO'])),
|
||||
],
|
||||
]),
|
||||
]);
|
||||
|
||||
$data = ['foo' => 3, 'bar' => 'HELLO'];
|
||||
@ -259,9 +260,9 @@ class AstFromValueTest extends TestCase
|
||||
|
||||
self::assertEquals(
|
||||
new ObjectValueNode([
|
||||
'fields' => [
|
||||
'fields' => new NodeList([
|
||||
$this->objectField('foo', new NullValueNode([])),
|
||||
],
|
||||
]),
|
||||
]),
|
||||
AST::astFromValue(['foo' => null], $inputObj)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user