You are here

ParentValue.php in GraphQL 8.4

File

src/GraphQL/Resolver/ParentValue.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 to the current value, which is the parent of the field.
 */
class ParentValue implements ResolverInterface {

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

}

Classes

Namesort descending Description
ParentValue Resolves to the current value, which is the parent of the field.