Automattic\WooCommerce\Vendor\GraphQL\Utils
SchemaPrinter::printSchemaDefinition
Method of the class: SchemaPrinter{}
No Hooks.
Returns
null. Nothing (null).
Usage
$result = SchemaPrinter::printSchemaDefinition( $schema ): ?string;
- $schema(Schema) (required)
- .
SchemaPrinter::printSchemaDefinition() SchemaPrinter::printSchemaDefinition code WC 10.9.1
protected static function printSchemaDefinition(Schema $schema): ?string
{
$queryType = $schema->getQueryType();
$mutationType = $schema->getMutationType();
$subscriptionType = $schema->getSubscriptionType();
// Special case: When a schema has no root operation types, no valid schema
// definition can be printed.
if ($queryType === null && $mutationType === null && $subscriptionType === null) {
return null;
}
// Only print a schema definition if there is a description or if it should
// not be omitted because of having default type names.
if ($schema->description !== null || ! static::hasDefaultRootOperationTypes($schema)) {
return static::printDescription([], $schema) . "schema {\n"
. ($queryType !== null ? " query: {$queryType->name}\n" : '')
. ($mutationType !== null ? " mutation: {$mutationType->name}\n" : '')
. ($subscriptionType !== null ? " subscription: {$subscriptionType->name}\n" : '')
. '}';
}
return null;
}