Skip to content

Instantly share code, notes, and snippets.

@blazeyo
Last active April 28, 2019 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blazeyo/b3c4e53563ab477898b63dc408d99f65 to your computer and use it in GitHub Desktop.
Save blazeyo/b3c4e53563ab477898b63dc408d99f65 to your computer and use it in GitHub Desktop.
<?php
namespace Drupal\my_module\Plugin\GraphQL\Fields\Entity;
use Drupal\Core\Entity\EntityInterface;
use Drupal\graphql\GraphQL\Execution\ResolveContext;
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
use GraphQL\Type\Definition\ResolveInfo;
/**
* @GraphQLField(
* id = "label",
* secure = true,
* name = "label",
* type = "String",
* parents = {"NodeArticle"}
* )
*/
class NodeStoryParagraphImage extends FieldPluginBase {
/**
* {@inheritdoc}
*/
public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
if ($value instanceof EntityInterface) {
return $value->label();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment