You are here

protected function ExampleSchemaExtension::addPageFields in GraphQL 8.4

Parameters

\Drupal\graphql\GraphQL\ResolverRegistryInterface $registry:

\Drupal\graphql\GraphQL\ResolverBuilder $builder:

1 call to ExampleSchemaExtension::addPageFields()
ExampleSchemaExtension::registerResolvers in examples/graphql_example/src/Plugin/GraphQL/SchemaExtension/ExampleSchemaExtension.php
Registers type and field resolvers in the shared registry.

File

examples/graphql_example/src/Plugin/GraphQL/SchemaExtension/ExampleSchemaExtension.php, line 33

Class

ExampleSchemaExtension
Plugin annotation @SchemaExtension( id = "example_extension", name = "Example extension", description = "A simple extension that adds node related fields.", schema = "example" )

Namespace

Drupal\graphql_examples\Plugin\GraphQL\SchemaExtension

Code

protected function addPageFields(ResolverRegistryInterface $registry, ResolverBuilder $builder) : void {
  $registry
    ->addFieldResolver('Page', 'id', $builder
    ->produce('entity_id')
    ->map('entity', $builder
    ->fromParent()));
  $registry
    ->addFieldResolver('Page', 'title', $builder
    ->compose($builder
    ->produce('entity_label')
    ->map('entity', $builder
    ->fromParent()), $builder
    ->produce('uppercase')
    ->map('string', $builder
    ->fromParent())));
}