Skip to content

Commit d317e94

Browse files
committed
Revert d7ada1b
1 parent fed0270 commit d317e94

File tree

4 files changed

+5
-459
lines changed

4 files changed

+5
-459
lines changed

features/graphql/mutation.feature

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -106,44 +106,6 @@ Feature: GraphQL mutation support
106106
And the JSON node "data.createDummy.arrayData[1]" should be equal to baz
107107
And the JSON node "data.createDummy.clientMutationId" should be equal to "myId"
108108

109-
Scenario: Create an item with an embedded field
110-
When I send the following GraphQL request:
111-
"""
112-
mutation {
113-
createRelatedDummy(input: {_id: 2, symfony: "symfony", embeddedDummy: {dummyName: "Embedded"}, clientMutationId: "myId"}) {
114-
id
115-
clientMutationId
116-
}
117-
}
118-
"""
119-
Then the response status code should be 200
120-
And the response should be in JSON
121-
And the header "Content-Type" should be equal to "application/json"
122-
And the JSON node "data.createRelatedDummy.id" should be equal to "/related_dummies/2"
123-
And the JSON node "data.createRelatedDummy.clientMutationId" should be equal to "myId"
124-
125-
Scenario: Create an item and update a nested resource through a mutation
126-
When I send the following GraphQL request:
127-
"""
128-
mutation {
129-
createRelationEmbedder(input: {paris: "paris", krondstadt: "Krondstadt", anotherRelated: {id: 2, symfony: "laravel"}, clientMutationId: "myId"}) {
130-
id
131-
anotherRelated {
132-
id
133-
symfony
134-
}
135-
clientMutationId
136-
}
137-
}
138-
"""
139-
Then the response status code should be 200
140-
And the response should be in JSON
141-
And the header "Content-Type" should be equal to "application/json"
142-
And the JSON node "data.createRelationEmbedder.id" should be equal to "/relation_embedders/1"
143-
And the JSON node "data.createRelationEmbedder.anotherRelated.id" should be equal to "/related_dummies/2"
144-
And the JSON node "data.createRelationEmbedder.anotherRelated.symfony" should be equal to "laravel"
145-
And the JSON node "data.createRelationEmbedder.clientMutationId" should be equal to "myId"
146-
147109
Scenario: Delete an item through a mutation
148110
When I send the following GraphQL request:
149111
"""

src/GraphQl/Type/Definition/InputUnionType.php

Lines changed: 0 additions & 187 deletions
This file was deleted.

src/GraphQl/Type/SchemaBuilder.php

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use ApiPlatform\Core\Exception\ResourceClassNotFoundException;
1717
use ApiPlatform\Core\GraphQl\Resolver\Factory\ResolverFactoryInterface;
1818
use ApiPlatform\Core\GraphQl\Serializer\ItemNormalizer;
19-
use ApiPlatform\Core\GraphQl\Type\Definition\InputUnionType;
2019
use ApiPlatform\Core\GraphQl\Type\Definition\IterableType;
2120
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
2221
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
@@ -343,24 +342,13 @@ private function convertType(Type $type, bool $input = false, string $mutationNa
343342
break;
344343
case Type::BUILTIN_TYPE_ARRAY:
345344
case Type::BUILTIN_TYPE_ITERABLE:
346-
$graphqlType = $this->getIterableType();
345+
if (!isset($this->graphqlTypes['#iterable'])) {
346+
$this->graphqlTypes['#iterable'] = new IterableType();
347+
}
348+
$graphqlType = $this->graphqlTypes['#iterable'];
347349
break;
348350
case Type::BUILTIN_TYPE_OBJECT:
349-
if ($input && $depth > 0) {
350-
if (!isset($this->graphqlTypes['#stringIterableUnionInput'])) {
351-
$this->graphqlTypes['#stringIterableUnionInput'] = new InputUnionType([
352-
'name' => 'StringIterableUnionInput',
353-
'description' => 'Resource\'s IRI or data (embedded entities or when updating a related existing resource)',
354-
'types' => [
355-
GraphQLType::string(),
356-
$this->getIterableType(),
357-
],
358-
]);
359-
}
360-
$graphqlType = $this->graphqlTypes['#stringIterableUnionInput'];
361-
break;
362-
}
363-
if (is_a($type->getClassName(), \DateTimeInterface::class, true)) {
351+
if (($input && $depth > 0) || is_a($type->getClassName(), \DateTimeInterface::class, true)) {
364352
$graphqlType = GraphQLType::string();
365353
break;
366354
}
@@ -511,15 +499,6 @@ private function getResourcePaginatedCollectionType(string $resourceClass, Graph
511499
return $this->graphqlTypes[$resourceClass]['connection'] = new ObjectType($configuration);
512500
}
513501

514-
private function getIterableType(): IterableType
515-
{
516-
if (!isset($this->graphqlTypes['#iterable'])) {
517-
$this->graphqlTypes['#iterable'] = new IterableType();
518-
}
519-
520-
return $this->graphqlTypes['#iterable'];
521-
}
522-
523502
private function isCollection(Type $type): bool
524503
{
525504
return $type->isCollection() && Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType();

0 commit comments

Comments
 (0)