mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Infer type name from className for enum and scalar types as well
This commit is contained in:
parent
f9740c5f2c
commit
19436c326d
@ -27,6 +27,10 @@ class EnumType extends Type implements InputType, OutputType, LeafType
|
||||
|
||||
public function __construct($config)
|
||||
{
|
||||
if (!isset($config['name'])) {
|
||||
$config['name'] = $this->tryInferName();
|
||||
}
|
||||
|
||||
Config::validate($config, [
|
||||
'name' => Config::STRING | Config::REQUIRED,
|
||||
'values' => Config::arrayOf([
|
||||
|
@ -28,6 +28,10 @@ abstract class ScalarType extends Type implements OutputType, InputType, LeafTyp
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (!isset($this->name)) {
|
||||
$this->name = $this->tryInferName();
|
||||
}
|
||||
|
||||
Utils::invariant($this->name, 'Type must be named.');
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user