final class UploadType extends ScalarType implements TypeInterface
27
{
28
public function __construct()
29
{
30
$this->name = 'Upload';
31
$this->description = 'The `Upload` type represents a file to be uploaded in the same HTTP request as specified by [graphql-multipart-request-spec](https://github.com/jaydenseric/graphql-multipart-request-spec).';
32
33
parent::__construct();
34
}
35
36
public function getName(): string
37
{
38
return $this->name;
39
}
40
41
/**
42
* {@inheritdoc}
43
*/
44
public function serialize($value)
45
{
46
throw new Error('`Upload` cannot be serialized.');
47
}
48
49
/**
50
* {@inheritdoc}
51
*/
52
public function parseValue($value): UploadedFile
53
{
54
if (!$value instanceof UploadedFile) {
55
throw new Error(sprintf('Could not get uploaded file, be sure to conform to GraphQL multipart request specification. Instead got: %s', Utils::printSafe($value)));
56
}
57
58
return $value;
59
}
60
61
/**
62
* {@inheritdoc}
63
*/
64
public function parseLiteral($valueNode, array $variables = null)
65
{
66
throw new Error('`Upload` cannot be hardcoded in query, be sure to conform to GraphQL multipart request specification.', $valueNode);