Skip to content

Commit 3357779

Browse files
lukaslueckealanpoulain
authored andcommitted
Make clientMutationId nullable (#2571)
1 parent d10a0f0 commit 3357779

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

features/graphql/mutation.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ Feature: GraphQL mutation support
5454
And the JSON node "data.createFoo.bar" should be equal to "new"
5555
And the JSON node "data.createFoo.clientMutationId" should be equal to "myId"
5656

57+
Scenario: Create an item without a clientMutationId
58+
When I send the following GraphQL request:
59+
"""
60+
mutation {
61+
createFoo(input: {name: "Created without mutation id", bar: "works"}) {
62+
id
63+
name
64+
bar
65+
}
66+
}
67+
"""
68+
Then the response status code should be 200
69+
And the response should be in JSON
70+
And the header "Content-Type" should be equal to "application/json"
71+
And the JSON node "data.createFoo.id" should be equal to "/foos/2"
72+
And the JSON node "data.createFoo.name" should be equal to "Created without mutation id"
73+
And the JSON node "data.createFoo.bar" should be equal to "works"
74+
5775
Scenario: Create an item with a subresource
5876
Given there are 1 dummy objects with relatedDummy
5977
When I send the following GraphQL request:

src/GraphQl/Type/SchemaBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ private function getResourceObjectTypeFields(?string $resourceClass, ResourceMet
441441
{
442442
$fields = [];
443443
$idField = ['type' => GraphQLType::nonNull(GraphQLType::id())];
444-
$clientMutationId = GraphQLType::nonNull(GraphQLType::string());
444+
$clientMutationId = GraphQLType::string();
445445

446446
if ('delete' === $mutationName || (null !== $ioMetadata && null === $ioMetadata['class'])) {
447447
return [

0 commit comments

Comments
 (0)