You are here

Value.php in GraphQL 8.4

File

src/GraphQL/Resolver/Value.php
View source
<?php

namespace Drupal\graphql\GraphQL\Resolver;

use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\graphql\GraphQL\Execution\FieldContext;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use GraphQL\Type\Definition\ResolveInfo;

/**
 * Resolves by returning the fixed value itself.
 */
class Value implements ResolverInterface {

  /**
   * Value to be resolved.
   *
   * @var mixed
   */
  protected $value;

  /**
   * Value constructor.
   *
   * @param mixed $value
   */
  public function __construct($value) {
    $this->value = $value;
  }

  /**
   * {@inheritdoc}
   */
  public function resolve($value, $args, ResolveContext $context, ResolveInfo $info, FieldContext $field) {
    if ($this->value instanceof CacheableDependencyInterface) {
      $context
        ->addCacheableDependency($this->value);
    }
    return $this->value;
  }

}

Classes

Namesort descending Description
Value Resolves by returning the fixed value itself.