File tree 5 files changed +91
-2
lines changed
src/Symfony/Bundle/Resources/config
TestBundle/ApiResource/Issue6354
5 files changed +91
-2
lines changed Original file line number Diff line number Diff line change @@ -1034,3 +1034,20 @@ Feature: GraphQL mutation support
1034
1034
"""
1035
1035
Then the response status code should be 200
1036
1036
And the JSON node "data.uploadMultipleMediaObject.mediaObject.contentUrl" should be equal to "test.gif"
1037
+
1038
+ @!mongodb
1039
+ Scenario : Mutation should run before validation
1040
+ When I send the following GraphQL request:
1041
+ """
1042
+ mutation {
1043
+ createActivityLog(input: {name: ""}) {
1044
+ activityLog {
1045
+ name
1046
+ }
1047
+ }
1048
+ }
1049
+ """
1050
+ Then the response status code should be 200
1051
+ And the response should be in JSON
1052
+ And the header "Content-Type" should be equal to "application/json"
1053
+ And the JSON node "data.createActivityLog.activityLog.name" should be equal to "hi"
Original file line number Diff line number Diff line change 158
158
<argument type =" tagged_locator" tag =" api_platform.parameter_provider" index-by =" key" />
159
159
</service >
160
160
161
- <!-- Validation occurs at 200, we want validation to be over when we reach custom resolvers -->
162
- <service id =" api_platform.graphql.state_provider.resolver" class =" ApiPlatform\GraphQl\State\Provider\ResolverProvider" decorates =" api_platform.graphql.state_provider" decoration-priority =" 190 " >
161
+ <!-- Validation occurs at 200, we want validation to be after we reach custom resolvers -->
162
+ <service id =" api_platform.graphql.state_provider.resolver" class =" ApiPlatform\GraphQl\State\Provider\ResolverProvider" decorates =" api_platform.graphql.state_provider" decoration-priority =" 220 " >
163
163
<argument type =" service" id =" api_platform.graphql.state_provider.resolver.inner" />
164
164
<argument type =" service" id =" api_platform.graphql.resolver_locator" />
165
165
</service >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the API Platform project.
5
+ *
6
+ * (c) Kévin Dunglas <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \Issue6354 ;
15
+
16
+ use ApiPlatform \Metadata \ApiResource ;
17
+ use ApiPlatform \Metadata \GraphQl \Mutation ;
18
+ use Symfony \Component \Validator \Constraints \NotBlank ;
19
+
20
+ #[ApiResource(
21
+ graphQlOperations: [
22
+ new Mutation (
23
+ resolver: 'app.graphql.mutation_resolver.activity_log ' ,
24
+ name: 'create '
25
+ ),
26
+ ]
27
+ )]
28
+ class ActivityLog
29
+ {
30
+ public function __construct (#[NotBlank()] public ?string $ name = null )
31
+ {
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of the API Platform project.
5
+ *
6
+ * (c) Kévin Dunglas <[email protected] >
7
+ *
8
+ * For the full copyright and license information, please view the LICENSE
9
+ * file that was distributed with this source code.
10
+ */
11
+
12
+ declare (strict_types=1 );
13
+
14
+ namespace ApiPlatform \Tests \Fixtures \TestBundle \ApiResource \Issue6354 ;
15
+
16
+ use ApiPlatform \GraphQl \Resolver \MutationResolverInterface ;
17
+
18
+ class CreateActivityLogResolver implements MutationResolverInterface
19
+ {
20
+ /**
21
+ * @param object|null $item
22
+ * @param mixed[] $context
23
+ */
24
+ public function __invoke ($ item , array $ context ): ActivityLog
25
+ {
26
+ if (!$ item instanceof ActivityLog) {
27
+ throw new \InvalidArgumentException ('Missing input of type ActivityLog ' );
28
+ }
29
+
30
+ $ item ->name = 'hi ' ;
31
+
32
+ return $ item ;
33
+ }
34
+ }
Original file line number Diff line number Diff line change @@ -455,3 +455,8 @@ services:
455
455
tags :
456
456
- name : ' api_platform.parameter_provider'
457
457
key : ' ApiPlatform\Tests\Fixtures\TestBundle\Parameter\CustomGroupParameterProvider'
458
+
459
+ app.graphql.mutation_resolver.activity_log :
460
+ class : ' ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue6354\CreateActivityLogResolver'
461
+ tags :
462
+ - name : ' api_platform.graphql.resolver'
You can’t perform that action at this time.
0 commit comments