class Manager implements ConfigurationApplier (View source)

Manager is the master container for a graphql endpoint, and contains all queries, mutations, and types.

Instantiate with {see \SilverStripe\GraphQL\Manager::createFromConfig()} with a config array.

Traits

Injectable
Extensible
Configurable

Constants

QUERY_ROOT

MUTATION_ROOT

TYPES_ROOT

Methods

getMiddlewares()

No description

$this
setMiddlewares(QueryMiddleware[] $middlewares)

No description

$this
addMiddleware(QueryMiddleware $middleware)

No description

__construct(string $schemaKey = null)

No description

static Manager
createFromConfig($config, string $schemaKey = null) deprecated

No description

configure()

Applies a configuration based on the schemaKey property

applyConfig(array $config)

No description

Schema
schema()

Build the main Schema instance that represents the final schema for this endpoint

array
query(string $query, array $params = [])

Execute an arbitrary operation (mutation / query) on this schema.

ExecutionResult|array
queryAndReturnResult(string $query, array $params = [])

Evaluate query via middleware

addType(Type $type, string $name = '')

Register a new type

Type
getType(string $name)

Return a type definition by name

bool
hasType(string $name)

No description

addQuery(array|Closure $query, string $name)

Register a new Query. Query can be defined as a closure to ensure dependent types are lazy loaded.

array
getQuery(string $name)

Get a query by name

addMutation(array|Closure $mutation, string $name)

Register a new mutation. Mutations can be callbacks to ensure dependent types are lazy-loaded.

array
getMutation(string $name)

Get a mutation by name

string
getSchemaKey()

No description

$this
setSchemaKey(string $schemaKey)

No description

static array
formatError(Error $exception)

More verbose error display defaults.

$this
setMember(Member $member)

Set the Member for the current context

Member
getMember()

Get the Member for the current context either from a previously set value or the current user

string
getQueryFromPersistedID($id)

get query from persisted id, return null if not found

$this
addContext(string $key, any $value)

No description

array
serialiseResult(ExecutionResult $executionResult)

Serialise a Graphql result object for output

Details

QueryMiddleware[] getMiddlewares()

Return Value

QueryMiddleware[]

$this setMiddlewares(QueryMiddleware[] $middlewares)

Parameters

QueryMiddleware[] $middlewares

Return Value

$this

$this addMiddleware(QueryMiddleware $middleware)

Parameters

QueryMiddleware $middleware

Return Value

$this

__construct(string $schemaKey = null)

Parameters

string $schemaKey

static Manager createFromConfig($config, string $schemaKey = null) deprecated

deprecated 4.0

Parameters

$config
string $schemaKey

Return Value

Manager

Manager configure()

Applies a configuration based on the schemaKey property

Return Value

Manager

Exceptions

Exception

applyConfig(array $config)

Parameters

array $config

Schema schema()

Build the main Schema instance that represents the final schema for this endpoint

Return Value

Schema

array query(string $query, array $params = [])

Execute an arbitrary operation (mutation / query) on this schema.

Note because middleware may produce serialised responses we need to conditionally normalise to serialised array on output from object -> array.

Parameters

string $query

Raw query

array $params

List of arguments given for this operation

Return Value

array

ExecutionResult|array queryAndReturnResult(string $query, array $params = [])

Evaluate query via middleware

Parameters

string $query
array $params

Return Value

ExecutionResult|array

Result as either source object result, or serialised as array.

addType(Type $type, string $name = '')

Register a new type

Parameters

Type $type
string $name

An optional identifier for this type (defaults to 'name' attribute in type definition). Needs to be unique in schema.

Type getType(string $name)

Return a type definition by name

Parameters

string $name

Return Value

Type

bool hasType(string $name)

Parameters

string $name

Return Value

bool

addQuery(array|Closure $query, string $name)

Register a new Query. Query can be defined as a closure to ensure dependent types are lazy loaded.

Parameters

array|Closure $query
string $name

Identifier for this query (unique in schema)

array getQuery(string $name)

Get a query by name

Parameters

string $name

Return Value

array

addMutation(array|Closure $mutation, string $name)

Register a new mutation. Mutations can be callbacks to ensure dependent types are lazy-loaded.

Parameters

array|Closure $mutation
string $name

Identifier for this mutation (unique in schema)

array getMutation(string $name)

Get a mutation by name

Parameters

string $name

Return Value

array

string getSchemaKey()

Return Value

string

$this setSchemaKey(string $schemaKey)

Parameters

string $schemaKey

Return Value

$this

static array formatError(Error $exception)

More verbose error display defaults.

Parameters

Error $exception

Return Value

array

$this setMember(Member $member)

Set the Member for the current context

Parameters

Member $member

Return Value

$this

Member getMember()

Get the Member for the current context either from a previously set value or the current user

Return Value

Member

string getQueryFromPersistedID($id)

get query from persisted id, return null if not found

Parameters

$id

Return Value

string

| null

$this addContext(string $key, any $value)

Parameters

string $key
any $value

Return Value

$this

array serialiseResult(ExecutionResult $executionResult)

Serialise a Graphql result object for output

Parameters

ExecutionResult $executionResult

Return Value

array