Skip to content

Commit c0f7bdb

Browse files
committed
GraphQL: improve error messange when mutation not allowed
1 parent 42128c1 commit c0f7bdb

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

features/graphql/mutation.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ Feature: GraphQL mutation support
135135
Then the response status code should be 200
136136
And the response should be in JSON
137137
And the header "Content-Type" should be equal to "application/json"
138-
And the JSON node "errors[0].message" should be equal to 'Item "/dummies/1" did not match expected type "ApiPlatform\Core\Tests\Fixtures\TestBundle\Entity\Foo".'
138+
And the JSON node "errors[0].message" should be equal to 'Item "/dummies/1" did not match expected type "Foo".'
139139

140140
@dropSchema
141141
Scenario: Delete an item with composite identifiers through a mutation

src/GraphQl/Resolver/Factory/ItemMutationResolverFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function __invoke(string $resourceClass = null, string $rootClass = null,
8585
}
8686

8787
if ($resourceClass !== $this->getObjectClass($item)) {
88-
throw Error::createLocatedError(sprintf('Item "%s" did not match expected type "%s".', $args['input']['id'], $resourceClass), $info->fieldNodes, $info->path);
88+
throw Error::createLocatedError(sprintf('Item "%s" did not match expected type "%s".', $args['input']['id'], $resourceMetadata->getShortName()), $info->fieldNodes, $info->path);
8989
}
9090
}
9191

0 commit comments

Comments
 (0)