Resolvers are not run on the default deletion mutation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in src/GraphQl/Resolver/Factory/ItemMutationResolverFactory.php and reproduce the issue with a GraphQL DeleteMutation that specifies a resolver and arguments. Verify that the configured resolver runs for the default deletion mutation, then run the relevant test suite to confirm the behavior.
Written by the indexing model from the issue text.
Description
API Platform version(s) affected: 3.1.3
Description
With GraphQL when we try to add a resolver on the delete mutation it doesn't work. It is not executed.
How to reproduce
#[ApiResource(
graphQlOperations: [
new Mutation(
resolver: CreateResolver::class,
args: [
'test' => [
'type' => 'String!',
]
],
name: 'create'
),
new DeleteMutation(
resolver: DeleteResolver::class,
args: [
'id' => [
'type' => 'ID!',
],
],
name: 'delete',
)
]
)]
Possible Solution
In src/GraphQl/Resolver/Factory/ItemMutationResolverFactory.php If the operation is "delete" the resolver are not executed because the resolver are executed after.
if ('delete' === $operation->getName() || $operation instanceof DeleteOperationInterface) {
($this->securityPostDenormalizeStage)($resourceClass, $operation, $resolverContext + [
'extra_variables' => [
'object' => $item,
'previous_object' => $previousItem,
],
]);
$item = ($this->writeStage)($item, $resourceClass, $operation, $resolverContext);
return ($this->serializeStage)($item, $resourceClass, $operation, $resolverContext);
}
$item = ($this->deserializeStage)($item, $resourceClass, $operation, $resolverContext);
$mutationResolverId = $operation->getResolver();
if (null !== $mutationResolverId) {
/** @var MutationResolverInterface $mutationResolver */
$mutationResolver = $this->mutationResolverLocator->get($mutationResolverId);
$item = $mutationResolver($item, $resolverContext);
if (null !== $item && $resourceClass !== $itemClass = $this->getObjectClass($item)) {
throw new \LogicException(sprintf('Custom mutation resolver "%s" has to return an item of class %s but returned an item of class %s.', $mutationResolverId, $operation->getShortName(), (new \ReflectionClass($itemClass))->getShortName()));
}
}
- Dominant language
- PHP
- Stars
- 2.6k
- Forks
- 984
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 87
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from api-platform/core
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
api-platform/core#8626 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
api-platform/core#8612 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
api-platform/core#8591 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
api-platform/core#8535 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
api-platform/core#8499 · 1 comment ·
Maintainers usually reply within 1 day
All issues in api-platform/core
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
unraid/webgui#2781 · 1 comment ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
symfony/maker-bundle#1841 ·
Maintainers usually reply within 1 day
-
type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
bug No Code Attached Yet
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
joomla/joomla-cms#48556 · 1 comment ·
Maintainers usually reply within 1 day
-
sync-en
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Maintainers usually reply within 1 day