Inheritance: extends Youshido\GraphQL\Config\AbstractConfig, implements Youshido\GraphQL\Config\TypeConfigInterface, use trait Youshido\GraphQL\Config\Traits\FieldsAwareConfigTrait
 protected function getConfigValue($key, $defaultValue = null)
 {
     if (array_key_exists($key, $this->configCache)) {
         return $this->configCache[$key];
     }
     $this->configCache[$key] = !empty($this->config) ? $this->config->get($key, $defaultValue) : $defaultValue;
     return $this->configCache[$key];
 }
Exemple #2
0
 /**
  * @param ObjectTypeConfig $config
  *
  * @return mixed
  */
 public function build($config)
 {
     $config->addFields(['id' => new IdType(), 'url' => new StringType(), new ResizedField()]);
 }
 public function testAddField()
 {
     $fieldsData = ['id' => ['type' => new IntType()]];
     $config = new ObjectTypeConfig(['name' => 'UserType', 'fields' => $fieldsData]);
     $this->assertTrue($config->hasFields());
     $idField = new Field(['name' => 'id', 'type' => new IntType()]);
     $idField->getName();
     $nameField = new Field(['name' => 'name', 'type' => new StringType()]);
     $this->assertEquals(['id' => $idField], $config->getFields());
     $config->addField($nameField);
     $this->assertEquals(['id' => $idField, 'name' => $nameField], $config->getFields());
     $config->removeField('id');
     $this->assertEquals(['name' => $nameField], $config->getFields());
     $config->addFields(['id' => $idField]);
     $this->assertEquals(['name' => $nameField, 'id' => $idField], $config->getFields());
     $levelField = new Field(['name' => 'level', 'type' => new IntType()]);
     $config->addFields([$levelField]);
     $this->assertEquals(['name' => $nameField, 'id' => $idField, 'level' => $levelField], $config->getFields());
 }
 public function testInterfaces()
 {
     $testInterfaceType = new TestInterfaceType();
     $config = new ObjectTypeConfig(['name' => 'Test', 'interfaces' => [$testInterfaceType]], null, false);
     $this->assertEquals($config->getInterfaces(), [$testInterfaceType]);
 }