Update input file scalar definition

This commit is contained in:
Jake Barnby 2022-07-07 12:54:59 +12:00
parent 23c52da9f8
commit 4ec637f889

View file

@ -6,23 +6,22 @@ namespace Appwrite\GraphQL\Types;
use GraphQL\Error\Error;
use GraphQL\Error\InvariantViolation;
use GraphQL\Language\AST\Node;
use GraphQL\Type\Definition\ScalarType;
use GraphQL\Utils\Utils;
use Psr\Http\Message\UploadedFileInterface;
use UnexpectedValueException;
class InputFile extends ScalarType
{
/**
* @var string
* @var string
*/
public $name = 'Upload';
public $name = 'InputFile';
/**
* @var string
*/
public $description
= 'The `Upload` special type represents a file to be uploaded in the same HTTP request as specified by
= 'The `InputFile` special 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).';
/**
@ -34,7 +33,7 @@ class InputFile extends ScalarType
*/
public function serialize($value)
{
throw new InvariantViolation('`Upload` cannot be serialized');
throw new InvariantViolation('`InputFile` cannot be serialized');
}
/**
@ -50,12 +49,13 @@ class InputFile extends ScalarType
/**
* Parses an externally provided literal value (hardcoded in GraphQL query) to use as an input.
*
* @param \GraphQL\Language\AST\Node $valueNode
* @param Node $valueNode
*
* @return mixed
* @throws Error
*/
public function parseLiteral($valueNode, ?array $variables = null)
{
throw new Error('`Upload` cannot be hardcoded in query, be sure to conform to GraphQL multipart request specification. Instead got: ' . $valueNode->kind, $valueNode);
throw new Error('`InputFile` cannot be hardcoded in query, be sure to conform to GraphQL multipart request specification. Instead got: ' . $valueNode->kind, $valueNode);
}
}