You are here

ThunderJsonLdSchemaExtension.php in Thunder 6.2.x

File

modules/thunder_gqls/src/Plugin/GraphQL/SchemaExtension/ThunderJsonLdSchemaExtension.php
View source
<?php

namespace Drupal\thunder_gqls\Plugin\GraphQL\SchemaExtension;

use Drupal\graphql\GraphQL\ResolverRegistryInterface;

/**
 * Extension to add the JSON-LD script tag query.
 *
 * @SchemaExtension(
 *   id = "thunder_jsonld",
 *   name = "JSON-LD extension",
 *   description = "Adds the JSON-LD script tag query.",
 *   schema = "thunder"
 * )
 */
class ThunderJsonLdSchemaExtension extends ThunderSchemaExtensionPluginBase {

  /**
   * {@inheritdoc}
   */
  public function registerResolvers(ResolverRegistryInterface $registry) {
    parent::registerResolvers($registry);
    $this
      ->addFieldResolverIfNotExists('Query', 'jsonld', $this->builder
      ->produce('thunder_entity_sub_request')
      ->map('path', $this->builder
      ->fromArgument('path'))
      ->map('key', $this->builder
      ->fromValue('jsonld')));
  }

}

Classes

Namesort descending Description
ThunderJsonLdSchemaExtension Extension to add the JSON-LD script tag query.