GraphQL\Type\Definition\ObjectType::getField PHP Method

getField() public method

public getField ( string $name ) : FieldDefinition
$name string
return FieldDefinition
    public function getField($name)
    {
        if (null === $this->fields) {
            $this->getFields();
        }
        if (!isset($this->fields[$name])) {
            throw new InvariantViolation(sprintf("Field '%s' is not defined for type '%s'", $name, $this->name));
        }
        return $this->fields[$name];
    }

Usage Example

Example #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);
 }
All Usage Examples Of GraphQL\Type\Definition\ObjectType::getField