WooCommerce Code Reference

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
phpstan-import-type

SchemaConfigOptions from SchemaConfig

phpstan-import-type

OperationType from OperationDefinitionNode

see
SchemaTest

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

Methods

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
throws
InvariantViolation
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
throws
InvariantViolation
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 definitions

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

loadType()

private loadType(string $typeName) : (\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type&\Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\NamedType)|null
Parameters
$typeName : string
Tags
throws
InvariantViolation
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>
Return values
array<string|int, \Automattic\WooCommerce\Vendor\GraphQL\Type\Definition\Type|callable>