You are here

EntityCrudOutputEntity.php in GraphQL 8.3

File

modules/graphql_core/src/Plugin/GraphQL/Fields/Mutations/EntityCrudOutputEntity.php
View source
<?php

namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Mutations;

use Drupal\graphql\GraphQL\Execution\ResolveContext;
use Drupal\graphql_core\GraphQL\EntityCrudOutputWrapper;
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
use GraphQL\Type\Definition\ResolveInfo;

/**
 * Retrieve a the mutated entity.
 *
 * @GraphQLField(
 *   id = "entity_crud_output_entity",
 *   secure = true,
 *   name = "entity",
 *   type = "Entity",
 *   parents = {"EntityCrudOutput"}
 * )
 */
class EntityCrudOutputEntity extends FieldPluginBase {

  /**
   * {@inheritdoc}
   */
  public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
    if ($value instanceof EntityCrudOutputWrapper) {
      if (($entity = $value
        ->getEntity()) && $entity
        ->access('view')) {
        (yield $entity);
      }
    }
  }

}

Classes

Namesort descending Description
EntityCrudOutputEntity Retrieve a the mutated entity.