You are here

protected function ExampleSchema::addConnectionFields in GraphQL 8.4

Parameters

string $type:

\Drupal\graphql\GraphQL\ResolverRegistry $registry:

\Drupal\graphql\GraphQL\ResolverBuilder $builder:

1 call to ExampleSchema::addConnectionFields()
ExampleSchema::getResolverRegistry in examples/graphql_example/src/Plugin/GraphQL/Schema/ExampleSchema.php
Retrieves the resolver registry.

File

examples/graphql_example/src/Plugin/GraphQL/Schema/ExampleSchema.php, line 87

Class

ExampleSchema
Plugin annotation @Schema( id = "example", name = "Example schema" )

Namespace

Drupal\graphql_examples\Plugin\GraphQL\Schema

Code

protected function addConnectionFields($type, ResolverRegistry $registry, ResolverBuilder $builder) : void {
  $registry
    ->addFieldResolver($type, 'total', $builder
    ->callback(function (QueryConnection $connection) {
    return $connection
      ->total();
  }));
  $registry
    ->addFieldResolver($type, 'items', $builder
    ->callback(function (QueryConnection $connection) {
    return $connection
      ->items();
  }));
}