public function SdlSchemaPluginBase::getSchema in GraphQL 8.4
Throws
\GraphQL\Error\SyntaxError
\GraphQL\Error\Error
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
Overrides SchemaPluginInterface::getSchema
File
- src/
Plugin/ GraphQL/ Schema/ SdlSchemaPluginBase.php, line 118
Class
- SdlSchemaPluginBase
- Base class that can be used by schema plugins.
Namespace
Drupal\graphql\Plugin\GraphQL\SchemaCode
public function getSchema(ResolverRegistryInterface $registry) {
$extensions = $this
->getExtensions();
$resolver = [
$registry,
'resolveType',
];
$document = $this
->getSchemaDocument($extensions);
$schema = BuildSchema::build($document, function ($config, TypeDefinitionNode $type) use ($resolver) {
if ($type instanceof InterfaceTypeDefinitionNode || $type instanceof UnionTypeDefinitionNode) {
$config['resolveType'] = $resolver;
}
return $config;
});
if (empty($extensions)) {
return $schema;
}
foreach ($extensions as $extension) {
$extension
->registerResolvers($registry);
}
if ($extendSchema = $this
->getExtensionDocument($extensions)) {
return SchemaExtender::extend($schema, $extendSchema);
}
return $schema;
}