You are here

protected function EventSchemaExtension::addQueryFields in Open Social 10.3.x

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 EventSchemaExtension::addQueryFields()
EventSchemaExtension::registerResolvers in modules/social_features/social_event/src/Plugin/GraphQL/SchemaExtension/EventSchemaExtension.php

File

modules/social_features/social_event/src/Plugin/GraphQL/SchemaExtension/EventSchemaExtension.php, line 143

Class

EventSchemaExtension
Adds event data to the Open Social GraphQL API.

Namespace

Drupal\social_event\Plugin\GraphQL\SchemaExtension

Code

protected function addQueryFields(ResolverRegistryInterface $registry, ResolverBuilder $builder) {
  $registry
    ->addFieldResolver('Query', 'events', $builder
    ->produce('query_event')
    ->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', 'event', $builder
    ->produce('entity_load_by_uuid')
    ->map('type', $builder
    ->fromValue('node'))
    ->map('bundles', $builder
    ->fromValue([
    'event',
  ]))
    ->map('uuid', $builder
    ->fromArgument('id')));
}