getDefinition() public static method

public static getDefinition ( ) : array
return array
Exemplo n.º 1
0
 public function __construct(array $config)
 {
     Config::validate($config, ['name' => Config::STRING, 'fields' => Config::arrayOf(FieldDefinition::getDefinition(), Config::KEY_AS_NAME), 'resolveType' => Config::CALLBACK, 'description' => Config::STRING]);
     $this->name = $config['name'];
     $this->description = isset($config['description']) ? $config['description'] : null;
     $this->_fields = !empty($config['fields']) ? FieldDefinition::createMap($config['fields']) : [];
     $this->_resolveTypeFn = isset($config['resolveType']) ? $config['resolveType'] : null;
 }
Exemplo n.º 2
0
 /**
  * InterfaceType constructor.
  * @param array $config
  */
 public function __construct(array $config)
 {
     if (!isset($config['name'])) {
         $config['name'] = $this->tryInferName();
     }
     Config::validate($config, ['name' => Config::NAME, 'fields' => Config::arrayOf(FieldDefinition::getDefinition(), Config::KEY_AS_NAME | Config::MAYBE_THUNK | Config::MAYBE_TYPE), 'resolveType' => Config::CALLBACK, 'description' => Config::STRING]);
     $this->name = $config['name'];
     $this->description = isset($config['description']) ? $config['description'] : null;
     $this->config = $config;
 }
Exemplo n.º 3
0
 /**
  * ObjectType constructor.
  * @param array $config
  */
 public function __construct(array $config)
 {
     if (!isset($config['name'])) {
         $config['name'] = $this->tryInferName();
     }
     Utils::invariant(!empty($config['name']), 'Every type is expected to have name');
     // Note: this validation is disabled by default, because it is resource-consuming
     // TODO: add bin/validate script to check if schema is valid during development
     Config::validate($config, ['name' => Config::NAME | Config::REQUIRED, 'fields' => Config::arrayOf(FieldDefinition::getDefinition(), Config::KEY_AS_NAME | Config::MAYBE_THUNK | Config::MAYBE_TYPE), 'description' => Config::STRING, 'interfaces' => Config::arrayOf(Config::INTERFACE_TYPE, Config::MAYBE_THUNK), 'isTypeOf' => Config::CALLBACK, 'resolveField' => Config::CALLBACK]);
     $this->name = $config['name'];
     $this->description = isset($config['description']) ? $config['description'] : null;
     $this->resolveFieldFn = isset($config['resolveField']) ? $config['resolveField'] : null;
     $this->config = $config;
 }
Exemplo n.º 4
0
 public function __construct(array $config)
 {
     Config::validate($config, ['name' => Config::STRING | Config::REQUIRED, 'fields' => Config::arrayOf(FieldDefinition::getDefinition(), Config::KEY_AS_NAME), 'description' => Config::STRING, 'interfaces' => Config::arrayOf(Config::INTERFACE_TYPE), 'isTypeOf' => Config::CALLBACK]);
     $this->name = $config['name'];
     $this->description = isset($config['description']) ? $config['description'] : null;
     if (isset($config['fields'])) {
         $this->_fields = FieldDefinition::createMap($config['fields']);
     }
     $this->_interfaces = isset($config['interfaces']) ? $config['interfaces'] : [];
     $this->_isTypeOf = isset($config['isTypeOf']) ? $config['isTypeOf'] : null;
     if (!empty($this->_interfaces)) {
         InterfaceType::addImplementationToInterfaces($this, $this->_interfaces);
     }
 }
Exemplo n.º 5
0
 /**
  * Late instance initialization
  */
 private function initialize()
 {
     if ($this->_initialized) {
         return;
     }
     $config = $this->_config;
     if (isset($config['fields']) && is_callable($config['fields'])) {
         $config['fields'] = call_user_func($config['fields']);
     }
     if (isset($config['interfaces']) && is_callable($config['interfaces'])) {
         $config['interfaces'] = call_user_func($config['interfaces']);
     }
     // Note: this validation is disabled by default, because it is resource-consuming
     // TODO: add bin/validate script to check if schema is valid during development
     Config::validate($this->_config, ['name' => Config::STRING | Config::REQUIRED, 'fields' => Config::arrayOf(FieldDefinition::getDefinition(), Config::KEY_AS_NAME), 'description' => Config::STRING, 'interfaces' => Config::arrayOf(Config::INTERFACE_TYPE), 'isTypeOf' => Config::CALLBACK, 'resolveField' => Config::CALLBACK]);
     $this->_fields = FieldDefinition::createMap($config['fields']);
     $this->_interfaces = isset($config['interfaces']) ? $config['interfaces'] : [];
     $this->_isTypeOf = isset($config['isTypeOf']) ? $config['isTypeOf'] : null;
     $this->_initialized = true;
 }