public static function EntitySchemaProvider::getEntitySingle in GraphQL 8.2
Same name and namespace in other branches
- 8 src/SchemaProvider/EntitySchemaProvider.php \Drupal\graphql\SchemaProvider\EntitySchemaProvider::getEntitySingle()
Single entity resolver callback.
File
- src/
SchemaProvider/ EntitySchemaProvider.php, line 164
Class
- EntitySchemaProvider
- Generates a GraphQL Schema for content entity types.
Namespace
Drupal\graphql\SchemaProviderCode
public static function getEntitySingle($source, array $args = NULL, $root, Node $field, $a, $b, $c, $data) {
// @todo Fix injection of container dependencies in resolver functions.
$storage = \Drupal::entityManager()
->getStorage($data['type']);
if ($entity = $storage
->load($args['id']) && $entity
->access('view')) {
return $entity
->getTypedData();
}
return NULL;
}