|
16 | 16 | use ApiPlatform\Core\Exception\ResourceClassNotFoundException; |
17 | 17 | use ApiPlatform\Core\GraphQl\Resolver\Factory\ResolverFactoryInterface; |
18 | 18 | use ApiPlatform\Core\GraphQl\Serializer\ItemNormalizer; |
19 | | -use ApiPlatform\Core\GraphQl\Type\Definition\InputUnionType; |
20 | 19 | use ApiPlatform\Core\GraphQl\Type\Definition\IterableType; |
21 | 20 | use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface; |
22 | 21 | use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface; |
@@ -343,24 +342,13 @@ private function convertType(Type $type, bool $input = false, string $mutationNa |
343 | 342 | break; |
344 | 343 | case Type::BUILTIN_TYPE_ARRAY: |
345 | 344 | 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']; |
347 | 349 | break; |
348 | 350 | 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)) { |
364 | 352 | $graphqlType = GraphQLType::string(); |
365 | 353 | break; |
366 | 354 | } |
@@ -511,15 +499,6 @@ private function getResourcePaginatedCollectionType(string $resourceClass, Graph |
511 | 499 | return $this->graphqlTypes[$resourceClass]['connection'] = new ObjectType($configuration); |
512 | 500 | } |
513 | 501 |
|
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 | | - |
523 | 502 | private function isCollection(Type $type): bool |
524 | 503 | { |
525 | 504 | return $type->isCollection() && Type::BUILTIN_TYPE_OBJECT === $type->getBuiltinType(); |
|
0 commit comments