You are here

protected function ExampleSchema::addQueryFields in GraphQL 8.4

Parameters

\Drupal\graphql\GraphQL\ResolverRegistry $registry:

\Drupal\graphql\GraphQL\ResolverBuilder $builder:

1 call to ExampleSchema::addQueryFields()
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 67

Class

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

Namespace

Drupal\graphql_examples\Plugin\GraphQL\Schema

Code

protected function addQueryFields(ResolverRegistry $registry, ResolverBuilder $builder) : void {
  $registry
    ->addFieldResolver('Query', 'article', $builder
    ->produce('entity_load')
    ->map('type', $builder
    ->fromValue('node'))
    ->map('bundles', $builder
    ->fromValue([
    'article',
  ]))
    ->map('id', $builder
    ->fromArgument('id')));
  $registry
    ->addFieldResolver('Query', 'articles', $builder
    ->produce('query_articles')
    ->map('offset', $builder
    ->fromArgument('offset'))
    ->map('limit', $builder
    ->fromArgument('limit')));
}