You are here

public function SchemaPluginBase::getSchema in GraphQL 8.3

Retrieves the schema.

Return value

\GraphQL\Type\Schema The schema.

Overrides SchemaPluginInterface::getSchema

1 call to SchemaPluginBase::getSchema()
SchemaPluginBase::getServer in src/Plugin/GraphQL/Schemas/SchemaPluginBase.php

File

src/Plugin/GraphQL/Schemas/SchemaPluginBase.php, line 197

Class

SchemaPluginBase

Namespace

Drupal\graphql\Plugin\GraphQL\Schemas

Code

public function getSchema() {
  $config = new SchemaConfig();
  if ($this
    ->hasMutations()) {
    $config
      ->setMutation(new ObjectType([
      'name' => 'Mutation',
      'fields' => function () {
        return $this
          ->getMutations();
      },
    ]));
  }
  if ($this
    ->hasSubscriptions()) {
    $config
      ->setSubscription(new ObjectType([
      'name' => 'Subscription',
      'fields' => function () {
        return $this
          ->getSubscriptions();
      },
    ]));
  }
  $config
    ->setQuery(new ObjectType([
    'name' => 'Query',
    'fields' => function () {
      return $this
        ->getFields('Root');
    },
  ]));
  $config
    ->setTypes(function () {
    return $this
      ->getTypes();
  });
  $config
    ->setTypeLoader(function ($name) {
    return $this
      ->getType($name);
  });
  return new Schema($config);
}