-
-
Notifications
You must be signed in to change notification settings - Fork 895
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(graphql): resolver before validation (#6363)
fixes #6354
- Loading branch information
Showing
5 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
tests/Fixtures/TestBundle/ApiResource/Issue6354/ActivityLog.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6354; | ||
|
||
use ApiPlatform\Metadata\ApiResource; | ||
use ApiPlatform\Metadata\GraphQl\Mutation; | ||
use Symfony\Component\Validator\Constraints\NotBlank; | ||
|
||
#[ApiResource( | ||
graphQlOperations: [ | ||
new Mutation( | ||
resolver: 'app.graphql.mutation_resolver.activity_log', | ||
name: 'create' | ||
), | ||
] | ||
)] | ||
class ActivityLog | ||
{ | ||
public function __construct(#[NotBlank()] public ?string $name = null) | ||
{ | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
tests/Fixtures/TestBundle/ApiResource/Issue6354/CreateActivityLogResolver.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6354; | ||
|
||
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface; | ||
|
||
class CreateActivityLogResolver implements MutationResolverInterface | ||
{ | ||
/** | ||
* @param object|null $item | ||
* @param mixed[] $context | ||
*/ | ||
public function __invoke($item, array $context): ActivityLog | ||
{ | ||
if (!$item instanceof ActivityLog) { | ||
throw new \InvalidArgumentException('Missing input of type ActivityLog'); | ||
} | ||
|
||
$item->name = 'hi'; | ||
|
||
return $item; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters