Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/Mappers/CannotMapTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ public static function createForParseError(Error $error): self
*/
public static function createForBadTypeInUnion(array $unionTypes): self
{
$disallowedTypes = array_filter($unionTypes, static function (Type $type) {
return $type instanceof NamedType;
});
$disallowedTypeNames = array_map(static function (NamedType $type) {
return $type->name;
}, $disallowedTypes);

return new self('In GraphQL, you can only use union types between objects. These types cannot be used in union types: ' . implode(', ', $disallowedTypeNames));
$disallowedTypeNames = array_map(static function (Type $type) {
if ($type instanceof NamedType) {
return $type->name;
}
return (string) $type;
}, $unionTypes);

return new self('in GraphQL, you can only use union types between objects. These types cannot be used in union types: ' . implode(', ', $disallowedTypeNames));
}

public static function mustBeOutputType(string $subTypeName): self
Expand Down
2 changes: 1 addition & 1 deletion tests/Mappers/Parameters/TypeMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function testMapScalarUnionException(): void
$docBlockObj = $cachedDocBlockFactory->getDocBlock($refMethod);

$this->expectException(CannotMapTypeException::class);
$this->expectExceptionMessage('In GraphQL, you can only use union types between objects. These types cannot be used in union types: Int, String');
$this->expectExceptionMessage('in GraphQL, you can only use union types between objects. These types cannot be used in union types: Int, String');
$typeMapper->mapReturnType($refMethod, $docBlockObj);
}

Expand Down