mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 15:59: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 = [];
|
$map = [];
|
||||||
foreach ($config as $name => $argConfig) {
|
foreach ($config as $name => $argConfig) {
|
||||||
|
if (!is_array($argConfig)) {
|
||||||
|
$argConfig = ['type' => $argConfig];
|
||||||
|
}
|
||||||
$map[] = new self($argConfig + ['name' => $name]);
|
$map[] = new self($argConfig + ['name' => $name]);
|
||||||
}
|
}
|
||||||
return $map;
|
return $map;
|
||||||
|
@ -16,7 +16,7 @@ class FieldDefinition
|
|||||||
public $name;
|
public $name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array<GraphQLFieldArgument>
|
* @var FieldArgument[]
|
||||||
*/
|
*/
|
||||||
public $args;
|
public $args;
|
||||||
|
|
||||||
|
@ -625,7 +625,13 @@ class DefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
'fields' => function() use (&$interface) {
|
'fields' => function() use (&$interface) {
|
||||||
return [
|
return [
|
||||||
'value' => Type::string(),
|
'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(Type::string(), $valueField->getType());
|
||||||
$this->assertEquals($interface, $nestedField->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');
|
$testField = $schema->getType('Query')->getField('test');
|
||||||
$this->assertEquals($interface, $testField->getType());
|
$this->assertEquals($interface, $testField->getType());
|
||||||
$this->assertEquals('test', $testField->name);
|
$this->assertEquals('test', $testField->name);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user