You are here

protected function OpenSocialBaseSchema::getBaseSchema in Open Social 10.0.x

Same name and namespace in other branches
  1. 10.3.x modules/custom/social_graphql/src/Plugin/GraphQL/Schema/OpenSocialBaseSchema.php \Drupal\social_graphql\Plugin\GraphQL\Schema\OpenSocialBaseSchema::getBaseSchema()
  2. 10.1.x modules/custom/social_graphql/src/Plugin/GraphQL/Schema/OpenSocialBaseSchema.php \Drupal\social_graphql\Plugin\GraphQL\Schema\OpenSocialBaseSchema::getBaseSchema()
  3. 10.2.x modules/custom/social_graphql/src/Plugin/GraphQL/Schema/OpenSocialBaseSchema.php \Drupal\social_graphql\Plugin\GraphQL\Schema\OpenSocialBaseSchema::getBaseSchema()

Provides a base schema for Open Social.

This ensures that other modules have common types available to them to build on.

Parameters

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

1 call to OpenSocialBaseSchema::getBaseSchema()
OpenSocialBaseSchema::getSchema in modules/custom/social_graphql/src/Plugin/GraphQL/Schema/OpenSocialBaseSchema.php

File

modules/custom/social_graphql/src/Plugin/GraphQL/Schema/OpenSocialBaseSchema.php, line 61

Class

OpenSocialBaseSchema
The provider of the schema base for the Open Social GraphQL API.

Namespace

Drupal\social_graphql\Plugin\GraphQL\Schema

Code

protected function getBaseSchema(ResolverRegistryInterface $registry) {
  $builder = new ResolverBuilder();

  // TextFormat fields.
  $registry
    ->addFieldResolver('TextFormat', 'name', $builder
    ->fromParent());

  // FormattedText fields.
  $registry
    ->addFieldResolver('FormattedText', 'format', $builder
    ->fromPath('text', 'format'));
  $registry
    ->addFieldResolver('FormattedText', 'raw', $builder
    ->fromPath('text', 'value'));

  // @todo https://www.drupal.org/project/social/issues/3191613
  $registry
    ->addFieldResolver('FormattedText', 'processed', $builder
    ->fromPath('text', 'processed'));

  // DateTime fields.
  // @todo https://www.drupal.org/project/social/issues/3191615
  $registry
    ->addFieldResolver('DateTime', 'timestamp', $builder
    ->fromParent());

  // Media fields.
  // @todo https://www.drupal.org/project/social/issues/3191617
  $registry
    ->addFieldResolver('Media', 'id', $builder
    ->produce('media_bridge')
    ->map('value', $builder
    ->fromParent())
    ->map('field', $builder
    ->fromValue('id')));
  $registry
    ->addFieldResolver('Media', 'url', $builder
    ->produce('media_bridge')
    ->map('value', $builder
    ->fromParent())
    ->map('field', $builder
    ->fromValue('url')));

  // Image fields.
  $registry
    ->addFieldResolver('Image', 'title', $builder
    ->produce('media_bridge')
    ->map('value', $builder
    ->fromParent())
    ->map('field', $builder
    ->fromValue('title')));
  $registry
    ->addFieldResolver('Image', 'alt', $builder
    ->produce('media_bridge')
    ->map('value', $builder
    ->fromParent())
    ->map('field', $builder
    ->fromValue('alt')));

  // Connection fields.
  $registry
    ->addFieldResolver('Connection', 'edges', $builder
    ->produce('connection_edges')
    ->map('connection', $builder
    ->fromParent()));
  $registry
    ->addFieldResolver('Connection', 'nodes', $builder
    ->produce('connection_nodes')
    ->map('connection', $builder
    ->fromParent()));
  $registry
    ->addFieldResolver('Connection', 'pageInfo', $builder
    ->produce('connection_page_info')
    ->map('connection', $builder
    ->fromParent()));

  // Edge fields.
  $registry
    ->addFieldResolver('Edge', 'cursor', $builder
    ->produce('edge_cursor')
    ->map('edge', $builder
    ->fromParent()));
  $registry
    ->addFieldResolver('Edge', 'node', $builder
    ->produce('edge_node')
    ->map('edge', $builder
    ->fromParent()));
}