ecodev / graphql-upload Goto Github PK
View Code? Open in Web Editor NEWA PSR-15 middleware to support file uploads in GraphQL
License: MIT License
A PSR-15 middleware to support file uploads in GraphQL
License: MIT License
Hey, I recently stumbled across this and project and I am using it and loving it, thanks for the great work!
I am using it in conjunction with PHP 8 and thecodingmachine/graphqlite.
graphqlite has a requirement for webonyx/graphql-php ^v0.13.4 (https://github.com/thecodingmachine/graphqlite/blob/master/composer.json#L14).
graphql-upload v6 requires webonyx/graphql-php ^14.
Therefore currently I can only use graphql-upload v5 together with graphqlite. But graqhl-upload v5 does not support PHP 8, so it is impossible to use graphql-php in my setup. That is why I created a fork and tagged a 5.0.1 which allows PHP 8.
This is all I had to do: svnldwg-forks@57b5d83
It works, but I would love to get rid of my fork and just use the original project. Could you allow PHP 8 for v5?
So just checking, this middleware only works with the zend framework?
Would you be interested in turning this package into a generic repository for graphql upload middlewares, e.g. I could create a LaravelUploadMiddleware
?
If you map indexes to the variables, but attach not enough uploads, the warning is shown. I think it should be an exception, maybe as a part of request validation.
It's caused by:
$items = $request->getUploadedFiles()[$fileKey];
When using this lib in middleware, the request body is parsed and re-attached to the request object that's piped through, if there are uploadedFiles. However, if there are not, the request is not parsed. Additionally, the stream is no longer available in the request object that's piped through the middleware, so you're unable to rewind and reparse, if needed.
This inconsistency is causing issues. I get that the request object needs to be modified, but the stream should at least be maintained, at the least. Or maybe just don't return a parsedBody at all. The real issue is that the parsing of the body isn't deep in it's JSON decoding. So, you can't even use it and you have to do a whole bunch of validation checks on the state of the parsedBody for it to be usable.
What is map parameter?
Can you give me some example?
thanks.
graphql-php version 15.0 released!
Seems like there is no issue to support both versions, so we could just bump package version
How to use postman
or insomnia
to test file upload?
What is the query looks like?
does UploadMiddleware works with slim middlework?
I have added this middleware to slim using
$app->add(new UploadMiddleware());
but it throws a below error
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "RuntimeException: {} is not resolvable in /var/www/html/php/vendor/slim/slim/Slim/CallableResolver.php:104"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "Stack trace:"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "#0 /var/www/html/php/vendor/slim/slim/Slim/CallableResolver.php(56): Slim\CallableResolver->assertCallable(Object(GraphQL\Upload\UploadMiddleware))"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "#1 /var/www/html/php/vendor/slim/slim/Slim/CallableResolverAwareTrait.php(45): Slim\CallableResolver->resolve(Object(GraphQL\Upload\UploadMiddleware))"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "#2 /var/www/html/php/vendor/slim/slim/Slim/DeferredCallable.php(36): Slim\DeferredCallable->resolveCallable(Object(GraphQL\Upload\UploadMiddleware))"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "#3 [internal function]: Slim\DeferredCallable->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "#4 /var/www/html/php/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(70): call_user_func(Object(Slim\DeferredCallable), Object(Slim\Http\Request), Object(Slim\Http\Response), Object(Closure))"
[22-Aug-2018 05:52:33] WARNING: [pool www] child 98 said into stderr: "#5 /var/www/html/php/vendor/tuupola/callable-handler/src/CallableHandler.php(34): Slim\App->Slim\{closure}(Object(Slim\Http\Request), Object(Slim\Http\Response))"
I mean https://github.com/Ecodev/graphql-upload/blob/master/composer.json#L27 .
This prevents to use current version of Webonyx, which is 0.11.* .
I was looking into adding uploads to graphql and i am using Folkloreatelier/laravel-graphql.
But I don't understand how to implement the middleware into Folkloreatelier/laravel-graphql.
As explained in #1 I should use a bridge. But I cant get it working. Could you help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.