protected function CreateEntityBase::resolveOutput in GraphQL 8.3
Formats the output of the mutation.
The default implementation wraps the created entity in another object to transport possible error messages and constraint violations after applying some access checks and input validation.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The created entity.
array $args: The arguments array.
\GraphQL\Type\Definition\ResolveInfo $info: The resolve info object.
Return value
mixed The output for the created entity.
1 call to CreateEntityBase::resolveOutput()
- CreateEntityBase::resolve in modules/
graphql_core/ src/ Plugin/ GraphQL/ Mutations/ Entity/ CreateEntityBase.php
File
- modules/
graphql_core/ src/ Plugin/ GraphQL/ Mutations/ Entity/ CreateEntityBase.php, line 138
Class
Namespace
Drupal\graphql_core\Plugin\GraphQL\Mutations\EntityCode
protected function resolveOutput(EntityInterface $entity, array $args, ResolveInfo $info) {
if (!$entity
->access('create')) {
return new EntityCrudOutputWrapper(NULL, NULL, [
$this
->t('You do not have the necessary permissions to create entities of this type.'),
]);
}
if ($entity instanceof ContentEntityInterface) {
if (($violations = $entity
->validate()) && $violations
->count()) {
return new EntityCrudOutputWrapper(NULL, $violations);
}
}
if (($status = $entity
->save()) && $status === SAVED_NEW) {
return new EntityCrudOutputWrapper($entity);
}
return NULL;
}