class Connection implements OperationResolver (View source)

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($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($args)

No description

$this
setDescription($string)

No description

string
getDescription()

No description

$this
setSortableFields(array $fields)

No description

array
getSortableFields()

No description

$this
setDefaultLimit($limit)

No description

int
getDefaultLimit()

No description

$this
setMaximumLimit($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

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

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

__construct(string $connectionName)

Parameters

string $connectionName

$this setConnectionResolver($func)

Parameters

$func

Return Value

$this

$this setConnectionType(ObjectType|callable $type)

Pass in the {@link ObjectType}.

Parameters

ObjectType|callable $type

Type, or callable to evaluate type

Return Value

$this

ObjectType|callable getConnectionType(bool $evaluate = true)

Evaluate Connection type

Parameters

bool $evaluate

Return Value

ObjectType|callable

callable getConnectionResolver()

Return Value

callable

$this setArgs($args)

Parameters

$args

Return Value

$this

$this setDescription($string)

Parameters

$string

Return Value

$this

string getDescription()

Return Value

string

$this setSortableFields(array $fields)

Parameters

array $fields

See {@link $sortableFields}

Return Value

$this

array getSortableFields()

Return Value

array

$this setDefaultLimit($limit)

Parameters

$limit

Return Value

$this

int getDefaultLimit()

Return Value

int

$this setMaximumLimit($limit)

Parameters

$limit

Return Value

$this

string getConnectionTypeName()

Return Value

string

string getEdgeTypeName()

Return Value

string

array args()

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

Return Value

array

array fields()

Return Value

array

ObjectType getEdgeType()

Return Value

ObjectType

ObjectType toType()

Return Value

ObjectType

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

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