class Manager implements ConfigurationApplier

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

Instantiate with {see 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

boolean
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

at line 94
QueryMiddleware[] getMiddlewares()

Return Value

QueryMiddleware[]

at line 103
$this setMiddlewares(QueryMiddleware[] $middlewares)

Parameters

QueryMiddleware[] $middlewares

Return Value

$this

at line 113
$this addMiddleware(QueryMiddleware $middleware)

Parameters

QueryMiddleware $middleware

Return Value

$this

at line 154
__construct(string $schemaKey = null)

Parameters

string $schemaKey

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

deprecated 4.0

Parameters

$config
string $schemaKey

Return Value

Manager

at line 182
Manager configure()

Applies a configuration based on the schemaKey property

Return Value

Manager

Exceptions

Exception

at line 202
applyConfig(array $config)

Parameters

array $config

at line 296
Schema schema()

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

Return Value

Schema

at line 342
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

at line 360
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.

at line 379
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.

at line 394
Type getType(string $name)

Return a type definition by name

Parameters

string $name

Return Value

Type

at line 408
boolean hasType(string $name)

Parameters

string $name

Return Value

boolean

at line 420
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)

at line 431
array getQuery(string $name)

Get a query by name

Parameters

string $name

Return Value

array

at line 443
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)

at line 454
array getMutation(string $name)

Get a mutation by name

Parameters

string $name

Return Value

array

at line 462
string getSchemaKey()

Return Value

string

at line 471
$this setSchemaKey(string $schemaKey)

Parameters

string $schemaKey

Return Value

$this

at line 503
static array formatError(Error $exception)

More verbose error display defaults.

Parameters

Error $exception

Return Value

array

at line 530
$this setMember(Member $member)

Set the Member for the current context

Parameters

Member $member

Return Value

$this

at line 541
Member getMember()

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

Return Value

Member

at line 552
string getQueryFromPersistedID($id)

get query from persisted id, return null if not found

Parameters

$id

Return Value

string | null

at line 588
$this addContext(string $key, any $value)

Parameters

string $key
any $value

Return Value

$this

at line 607
array serialiseResult(ExecutionResult $executionResult)

Serialise a Graphql result object for output

Parameters

ExecutionResult $executionResult

Return Value

array