Youshido\GraphQL\Relay\Connection\Connection::edgeDefinition PHP Method

edgeDefinition() public static method

public static edgeDefinition ( AbstractType $type, null | string $name = null, array $config = [] ) : ObjectType
$type Youshido\GraphQL\Type\AbstractType
$name null | string
$config array
return Youshido\GraphQL\Type\Object\ObjectType
    public static function edgeDefinition(AbstractType $type, $name = null, $config = [])
    {
        $name = $name ?: $type->getName();
        $edgeFields = !empty($config['edgeFields']) ? $config['edgeFields'] : [];
        $edgeType = new ObjectType(['name' => $name . 'Edge', 'description' => 'An edge in a connection.', 'fields' => array_merge(['node' => ['type' => $type, 'description' => 'The item at the end of the edge', 'resolve' => [__CLASS__, 'getNode']], 'cursor' => ['type' => TypeMap::TYPE_STRING, 'description' => 'A cursor for use in pagination']], $edgeFields)]);
        return $edgeType;
    }

Usage Example

Esempio n. 1
0
 public function testEdgeDefinition()
 {
     $edgeType = Connection::edgeDefinition(new StringType(), 'user');
     $this->assertEquals('userEdge', $edgeType->getName());
     $this->assertTrue($edgeType->hasField('node'));
     $this->assertTrue($edgeType->hasField('cursor'));
 }
All Usage Examples Of Youshido\GraphQL\Relay\Connection\Connection::edgeDefinition