Skip to content

Commit 2232021

Browse files
author
Mikk Mihkel Nurges
authored
Fixed dynamic upload type name (#126)
1 parent a624fdf commit 2232021

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ any effect...
516516
return [
517517
'profilePicture' => [
518518
'name' => 'profilePicture',
519-
'type' => new UploadType(), // <-- Here is used new type
519+
'type' => new UploadType($this->attributes['name']),
520520
'rules' => ['required', 'image', 'max:1500'],
521521
],
522522
];

src/Rebing/GraphQL/GraphQLUploadMiddleware.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
namespace Rebing\GraphQL;
64

75
use Closure;
@@ -91,7 +89,7 @@ private function parseUploadedFiles(Request $request)
9189
*
9290
* @param \Illuminate\Http\Request $request
9391
*/
94-
private function validateParsedBody(Request $request): void
92+
private function validateParsedBody(Request $request)
9593
{
9694
$bodyParams = $request->all();
9795

src/Rebing/GraphQL/Support/UploadType.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<?php
22

3-
declare(strict_types=1);
4-
53
namespace Rebing\GraphQL\Support;
64

75
use GraphQL\Error\Error;
@@ -10,8 +8,8 @@
108
use GraphQL\Utils\Utils;
119
use \Illuminate\Http\UploadedFile;
1210

13-
class UploadType extends ScalarType
14-
{
11+
class UploadType extends ScalarType {
12+
1513
/**
1614
* @var string
1715
*/
@@ -24,6 +22,13 @@ class UploadType extends ScalarType
2422
'The `Upload` special type represents a file to be uploaded in the same HTTP request as specified by
2523
[graphql-multipart-request-spec](https://github.com/jaydenseric/graphql-multipart-request-spec).';
2624

25+
public function __construct($name = 'Upload')
26+
{
27+
$this->name = $name . '_upload';
28+
29+
parent::__construct();
30+
}
31+
2732
/**
2833
* Serializes an internal value to include in a response.
2934
*

0 commit comments

Comments
 (0)