You are here

protected function CommentSchemaExtension::addQueryFields in Open Social 10.2.x

Same name and namespace in other branches
  1. 10.3.x modules/social_features/social_comment/src/Plugin/GraphQL/SchemaExtension/CommentSchemaExtension.php \Drupal\social_comment\Plugin\GraphQL\SchemaExtension\CommentSchemaExtension::addQueryFields()

Registers type and field resolvers in the query type.

Parameters

\Drupal\graphql\GraphQL\ResolverRegistryInterface $registry: The resolver registry.

\Drupal\graphql\GraphQL\ResolverBuilder $builder: The resolver builder.

1 call to CommentSchemaExtension::addQueryFields()
CommentSchemaExtension::registerResolvers in modules/social_features/social_comment/src/Plugin/GraphQL/SchemaExtension/CommentSchemaExtension.php

File

modules/social_features/social_comment/src/Plugin/GraphQL/SchemaExtension/CommentSchemaExtension.php, line 73

Class

CommentSchemaExtension
Adds comment data to the Open Social GraphQL API.

Namespace

Drupal\social_comment\Plugin\GraphQL\SchemaExtension

Code

protected function addQueryFields(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
  $registry
    ->addFieldResolver('Query', 'comments', $builder
    ->produce('query_comments')
    ->map('after', $builder
    ->fromArgument('after'))
    ->map('before', $builder
    ->fromArgument('before'))
    ->map('first', $builder
    ->fromArgument('first'))
    ->map('last', $builder
    ->fromArgument('last'))
    ->map('reverse', $builder
    ->fromArgument('reverse'))
    ->map('sortKey', $builder
    ->fromArgument('sortKey')));
  $registry
    ->addFieldResolver('Query', 'comment', $builder
    ->produce('entity_load_by_uuid')
    ->map('type', $builder
    ->fromValue('comment'))
    ->map('bundles', $builder
    ->fromValue([
    'comment',
  ]))
    ->map('uuid', $builder
    ->fromArgument('id')));
}