class Connection implements OperationResolver

A connection to a list of items on a object type. Collections are paginated and return a list of edges.

friends(limit:2,offset:2,sortBy:[{field:Name,direction:ASC}]) { edges { node { name } } pageInfo { totalCount hasPreviousPage hasNextPage } }

Traits

A class that can be instantiated or replaced via DI

Methods

static Injectable
create(array $args)

An implementation of the factory method, allows you to create an instance of a class

static Injectable
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

__construct(string $connectionName)

No description

$this
setConnectionResolver(Callable $func)

No description

$this
setConnectionType(ObjectType|Callable $type)

Pass in the {@link ObjectType}.

ObjectType|Callable
getConnectionType(bool $evaluate = true)

Evaluate Connection type

Callable
getConnectionResolver()

No description

$this
setArgs(array|Callable $args)

No description

$this
setDescription(string $string)

No description

string
getDescription()

No description

$this
setSortableFields(array $fields)

No description

array
getSortableFields()

No description

$this
setDefaultLimit(int $limit)

No description

int
getDefaultLimit()

No description

$this
setMaximumLimit(int $limit)

No description

string
getConnectionTypeName()

No description

string
getEdgeTypeName()

No description

array
args()

Pagination support for the connection type. Currently doesn't support cursors, just basic offset pagination.

array
fields()

No description

ObjectType
getEdgeType()

No description

ObjectType
toType()

No description

mixed
resolve(mixed $value, array $args, mixed $context, ResolveInfo $info)

Returns the collection resolved with the pageInfo provided.

array
resolveList(SS_List $list, array $args, null $context = null, ResolveInfo $info = null)

Wraps an {@link SS_List} with the required data in order to return it as a response. If you wish to resolve a standard array as a list use {@link ArrayList}.

Details

in Injectable at line 26
static Injectable create(array $args)

An implementation of the factory method, allows you to create an instance of a class

This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.

This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();

Parameters

array $args

Return Value

Injectable

in Injectable at line 43
static Injectable singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Parameters

string $class Optional classname to create, if the called class should not be used

Return Value

Injectable The singleton instance

$this setPermissionChecker(QueryPermissionChecker $checker)

Parameters

QueryPermissionChecker $checker

Return Value

$this

QueryPermissionChecker getPermissionChecker()

Return Value

QueryPermissionChecker

at line 91
__construct(string $connectionName)

Parameters

string $connectionName

at line 101
$this setConnectionResolver(Callable $func)

Parameters

Callable $func

Return Value

$this

at line 114
$this setConnectionType(ObjectType|Callable $type)

Pass in the {@link ObjectType}.

Parameters

ObjectType|Callable $type Type, or callable to evaluate type

Return Value

$this

at line 127
ObjectType|Callable getConnectionType(bool $evaluate = true)

Evaluate Connection type

Parameters

bool $evaluate

Return Value

ObjectType|Callable

at line 137
Callable getConnectionResolver()

Return Value

Callable

at line 147
$this setArgs(array|Callable $args)

Parameters

array|Callable $args

Return Value

$this

at line 159
$this setDescription(string $string)

Parameters

string $string

Return Value

$this

at line 169
string getDescription()

Return Value

string

at line 178
$this setSortableFields(array $fields)

Parameters

array $fields See {@link $sortableFields}

Return Value

$this

at line 190
array getSortableFields()

Return Value

array

at line 200
$this setDefaultLimit(int $limit)

Parameters

int $limit

Return Value

$this

at line 210
int getDefaultLimit()

Return Value

int

at line 220
$this setMaximumLimit(int $limit)

Parameters

int $limit

Return Value

$this

at line 230
string getConnectionTypeName()

Return Value

string

at line 238
string getEdgeTypeName()

Return Value

string

at line 249
array args()

Pagination support for the connection type. Currently doesn't support cursors, just basic offset pagination.

Return Value

array

at line 282
array fields()

Return Value

array

at line 301
ObjectType getEdgeType()

Return Value

ObjectType

at line 327
ObjectType toType()

Return Value

ObjectType

at line 348
mixed resolve(mixed $value, array $args, mixed $context, ResolveInfo $info)

Returns the collection resolved with the pageInfo provided.

Parameters

mixed $value
array $args
mixed $context
ResolveInfo $info

Return Value

mixed

Exceptions

Exception

at line 373
array resolveList(SS_List $list, array $args, null $context = null, ResolveInfo $info = null)

Wraps an {@link SS_List} with the required data in order to return it as a response. If you wish to resolve a standard array as a list use {@link ArrayList}.

Parameters

SS_List $list
array $args
null $context
ResolveInfo $info

Return Value

array