Schema
in package
Schema Definition (see [schema definition docs](schema-definition.md)).
A Schema is created by supplying the root types of each type of operation: query, mutation (optional) and subscription (optional). A schema definition is then supplied to the validator and executor. Usage Example:
$schema = new Automattic\WooCommerce\Vendor\GraphQL\Type\Schema([
'query' => $MyAppQueryRootType,
'mutation' => $MyAppMutationRootType,
]);
Or using Schema Config instance:
$config = Automattic\WooCommerce\Vendor\GraphQL\Type\SchemaConfig::create()
->setQuery($MyAppQueryRootType)
->setMutation($MyAppMutationRootType);
$schema = new Automattic\WooCommerce\Vendor\GraphQL\Type\Schema($config);
Tags
Table of Contents
- $astNode : SchemaDefinitionNode|null
- $description : string|null
- $extensionASTNodes : array<string|int, mixed>
- $config : SchemaConfig
- $fullyLoaded : bool
- True when $resolvedTypes contains all possible schema types.
- $implementationsMap : array<string|int, mixed>
- Lazily initialised.
- $resolvedTypes : array<string|int, mixed>
- Contains currently resolved schema types.
- $scalarOverrides : array<string|int, mixed>|null
- $validationErrors : array<string|int, mixed>
- __construct() : mixed
- assertValid() : void
- Throws if the schema is not valid.
- getConfig() : SchemaConfig
- getDirective() : Directive|null
- Returns instance of directive by name.
- getDirectives() : array<string|int, Directive>
- Returns a list of directives supported by this schema.
- getImplementations() : InterfaceImplementations
- Returns all types that implement a given interface type.
- getMutationType() : ObjectType|null
- Returns root mutation type.
- getOperationType() : ObjectType|null
- Returns root type by operation name.
- getPossibleTypes() : array<string|int, ObjectType>
- Returns all possible concrete types for given abstract type (implementations for interfaces and members of union type for unions).
- getQueryType() : ObjectType|null
- Returns root query type.
- getSubscriptionType() : ObjectType|null
- Returns schema subscription.
- getType() : (\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null
- Returns a type by name.
- getTypeMap() : array<string, \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType>
- Returns all types in this schema.
- hasType() : bool
- isSubType() : bool
- Returns true if the given type is a sub type of the given abstract type.
- resolveType() : Type
- typeLoaderNotType() : string
- typeLoaderWrongTypeName() : string
- validate() : array<int, Error>
- Validate the schema and return any errors.
- collectImplementations() : array<string, InterfaceImplementations>
- getScalarOverrides() : array<string, ScalarType>
- loadType() : (\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null
- materializeTypes() : array<string|int, \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|callable>
- Resolve config->types to an array, materializing callables and generators.
Properties
$astNode
public
SchemaDefinitionNode|null
$astNode
$description
public
string|null
$description
$extensionASTNodes
public
array<string|int, mixed>
$extensionASTNodes
= []
$config
private
SchemaConfig
$config
$fullyLoaded
True when $resolvedTypes contains all possible schema types.
private
bool
$fullyLoaded
= false
$implementationsMap
Lazily initialised.
private
array<string|int, mixed>
$implementationsMap
$resolvedTypes
Contains currently resolved schema types.
private
array<string|int, mixed>
$resolvedTypes
= []
$scalarOverrides
private
array<string|int, mixed>|null
$scalarOverrides
= null
$validationErrors
private
array<string|int, mixed>
$validationErrors
Methods
__construct()
public
__construct(SchemaConfig|array<string, mixed> $config) : mixed
Parameters
- $config : SchemaConfig|array<string, mixed>
Tags
Return values
mixed —assertValid()
Throws if the schema is not valid.
public
assertValid() : void
This operation requires a full schema scan. Do not use in production environment.
Tags
Return values
void —getConfig()
public
getConfig() : SchemaConfig
Return values
SchemaConfig —getDirective()
Returns instance of directive by name.
public
getDirective(string $name) : Directive|null
Parameters
- $name : string
Tags
Return values
Directive|null —getDirectives()
Returns a list of directives supported by this schema.
public
getDirectives() : array<string|int, Directive>
Tags
Return values
array<string|int, Directive> —getImplementations()
Returns all types that implement a given interface type.
public
getImplementations(InterfaceType $abstractType) : InterfaceImplementations
This operation requires full schema scan. Do not use in production environment.
Parameters
- $abstractType : InterfaceType
Tags
Return values
InterfaceImplementations —getMutationType()
Returns root mutation type.
public
getMutationType() : ObjectType|null
Return values
ObjectType|null —getOperationType()
Returns root type by operation name.
public
getOperationType(string $operation) : ObjectType|null
Parameters
- $operation : string
Return values
ObjectType|null —getPossibleTypes()
Returns all possible concrete types for given abstract type (implementations for interfaces and members of union type for unions).
public
getPossibleTypes(AbstractType|Type $abstractType) : array<string|int, ObjectType>
This operation requires full schema scan. Do not use in production environment.
Parameters
- $abstractType : AbstractType|Type
Tags
Return values
array<string|int, ObjectType> —getQueryType()
Returns root query type.
public
getQueryType() : ObjectType|null
Return values
ObjectType|null —getSubscriptionType()
Returns schema subscription.
public
getSubscriptionType() : ObjectType|null
Return values
ObjectType|null —getType()
Returns a type by name.
public
getType(string $name) : (\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null
Parameters
- $name : string
Tags
Return values
(\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null —getTypeMap()
Returns all types in this schema.
public
getTypeMap() : array<string, \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType>
This operation requires a full schema scan. Do not use in production environment.
Tags
Return values
array<string, \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType> — Keys represent type names, values are instances of corresponding type definitionshasType()
public
hasType(string $name) : bool
Parameters
- $name : string
Tags
Return values
bool —isSubType()
Returns true if the given type is a sub type of the given abstract type.
public
isSubType(AbstractType|Type $abstractType, ImplementingType|Type $maybeSubType) : bool
Parameters
- $abstractType : AbstractType|Type
- $maybeSubType : ImplementingType|Type
Tags
Return values
bool —resolveType()
public
static resolveType(Type|callable $type) : Type
Parameters
- $type : Type|callable
Tags
Return values
Type —typeLoaderNotType()
public
static typeLoaderNotType(mixed $typeLoaderReturn) : string
Parameters
- $typeLoaderReturn : mixed
-
could be anything
Return values
string —typeLoaderWrongTypeName()
public
static typeLoaderWrongTypeName(string $expectedTypeName, string $actualTypeName) : string
Parameters
- $expectedTypeName : string
- $actualTypeName : string
Return values
string —validate()
Validate the schema and return any errors.
public
validate() : array<int, Error>
This operation requires a full schema scan. Do not use in production environment.
Tags
Return values
array<int, Error> —collectImplementations()
private
collectImplementations() : array<string, InterfaceImplementations>
Tags
Return values
array<string, InterfaceImplementations> —getScalarOverrides()
private
getScalarOverrides() : array<string, ScalarType>
Return values
array<string, ScalarType> —loadType()
private
loadType(string $typeName) : (\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null
Parameters
- $typeName : string
Tags
Return values
(\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null —materializeTypes()
Resolve config->types to an array, materializing callables and generators.
private
materializeTypes() : array<string|int, \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|callable>
