getField() public method

public getField ( string $name ) : FieldDefinition
$name string
return FieldDefinition
示例#1
0
 public function testDefinesAMutationSchema()
 {
     $schema = new Schema($this->blogQuery, $this->blogMutation);
     $this->assertSame($this->blogMutation, $schema->getMutationType());
     $writeMutation = $this->blogMutation->getField('writeArticle');
     $this->assertInstanceOf('GraphQL\\Type\\Definition\\FieldDefinition', $writeMutation);
     $this->assertSame($this->blogArticle, $writeMutation->getType());
     $this->assertSame('Article', $writeMutation->getType()->name);
     $this->assertSame('writeArticle', $writeMutation->name);
 }
示例#2
0
 /**
  * Add edge instance.
  *
  * @param  ObjectType $type
  * @param  string     $name
  * @return void
  */
 public function addEdge(ObjectType $type, $name)
 {
     if ($edges = $type->getField('edges')) {
         $type = $edges->getType()->getWrappedType();
         $this->edgeInstances->put($name, $type);
     }
 }
示例#3
0
 public function testInputObjectTypeAllowsRecursiveDefinitions()
 {
     $called = false;
     $inputObject = new InputObjectType(['name' => 'InputObject', 'fields' => function () use(&$inputObject, &$called) {
         $called = true;
         return ['value' => ['type' => Type::string()], 'nested' => ['type' => $inputObject]];
     }]);
     $someMutation = new ObjectType(['name' => 'SomeMutation', 'fields' => ['mutateSomething' => ['type' => $this->blogArticle, 'args' => ['input' => ['type' => $inputObject]]]]]);
     $schema = new Schema(['query' => $this->blogQuery, 'mutation' => $someMutation]);
     $this->assertTrue($called);
     $this->assertSame($inputObject, $schema->getType('InputObject'));
     $this->assertEquals(count($inputObject->getFields()), 2);
     $this->assertSame($inputObject->getField('nested')->getType(), $inputObject);
     $this->assertSame($someMutation->getField('mutateSomething')->getArg('input')->getType(), $inputObject);
 }