mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Added missing one-line shorthand for field arguments
This commit is contained in:
parent
fc37515ec2
commit
3ba187ec04
@ -48,6 +48,9 @@ class FieldArgument
|
||||
{
|
||||
$map = [];
|
||||
foreach ($config as $name => $argConfig) {
|
||||
if (!is_array($argConfig)) {
|
||||
$argConfig = ['type' => $argConfig];
|
||||
}
|
||||
$map[] = new self($argConfig + ['name' => $name]);
|
||||
}
|
||||
return $map;
|
||||
|
@ -16,7 +16,7 @@ class FieldDefinition
|
||||
public $name;
|
||||
|
||||
/**
|
||||
* @var array<GraphQLFieldArgument>
|
||||
* @var FieldArgument[]
|
||||
*/
|
||||
public $args;
|
||||
|
||||
|
@ -625,7 +625,13 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
'fields' => function() use (&$interface) {
|
||||
return [
|
||||
'value' => Type::string(),
|
||||
'nested' => $interface
|
||||
'nested' => $interface,
|
||||
'withArg' => [
|
||||
'type' => Type::string(),
|
||||
'args' => [
|
||||
'arg1' => Type::int()
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
]);
|
||||
@ -647,6 +653,12 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(Type::string(), $valueField->getType());
|
||||
$this->assertEquals($interface, $nestedField->getType());
|
||||
|
||||
$withArg = $schema->getType('SomeInterface')->getField('withArg');
|
||||
$this->assertEquals(Type::string(), $withArg->getType());
|
||||
|
||||
$this->assertEquals('arg1', $withArg->args[0]->name);
|
||||
$this->assertEquals(Type::int(), $withArg->args[0]->getType());
|
||||
|
||||
$testField = $schema->getType('Query')->getField('test');
|
||||
$this->assertEquals($interface, $testField->getType());
|
||||
$this->assertEquals('test', $testField->name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user