-
-
Notifications
You must be signed in to change notification settings - Fork 562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Support for file uploads #220
Conversation
This revert webonyx#202 (commit 9d37f4c) because trying to parse PSR-7 request was a mistake. The whole point of PSR-7 is to allow for interoperability and be able to use specialized libs for body parsing (amongst many other things). Trying to parse ourselves would be opening a can of worm if/when other content types have to be supported. It is more correct and future safe to require that the body is parsed before being passed to GraphQL.
Looks awesome, but I have couple notes:
Please let me know what you think. |
I suspected you would say that. I really don't mind at all. I would tend to go
I am not sure about that. I am actually not sure about the "raw" server at all. I feel supporting raw request (as opposed to PSR request) double our workload for really no gain. It's very easy to add a PSR compliant lib to parse globals just before calling the standard server. Supporting "raw" request is definitely convenient for new users, but I feel like it will bite us in the end, because we have to re-implement lots of PSR related things and maintain two very similar yet different paths in our code (one for raw, and one for PSR). Instead of implementing
This might be a deal breaker for me. I use Apollo Client on the browser side and it seemed to me that I am not quite sure, but it seems that what What do you use on client side ? would you have a suggestion to combine |
We have a separate endpoint for file uploads (not doing it via GraphQL). And also use our own simple GraphQL client (not Apollo or Relay) I actually didn't realize that you want to implement some 3rd-party spec, just thought we'll mirror As for I think it's better to extract this implementation as a separate project (same way as apollo-upload-server is separate from apollo-server). But still, the question remains if we can make life simpler in a Standard Server for those using such tools. |
Actually apollo-server (at least for express) uses the same approach as express-server, so this actually looks like a standard for me. P.S. I somehow managed to miss the part about |
Fair enough, I'll extract this PR as an independent project for the time being, and we can always re-consider the situation if/when a standard more clearly emerges. |
Just released graphql-upload 1.0.0 for anyone interested... |
This is a work in progress to implement GraphQL multipart request specification to support file uploads.
The
StandardServer
now supports file uploads for request withmultipart/form-data
content type, but only for PSR-7 requests (IMHO it would be out of scope to parse raw request for uploaded files). A new typeFile
was introduced to represent uploaded file in the schema.Usage should look like:
On the implementation side of things, I would need advice on how to properly test
\GraphQL\Type\Definition\FileType
. For now we have\GraphQL\Tests\Executor\UploadTest
which is more or less a functionnal tests for the entire stack. It's nice and working, but it only test a single case. It might be best to have unit tests covering onlyFileType
, with more different cases, but I could not find anything similar. Would you have any recommendations about that ? where and how it should be done ?Like I mentionned it includes PR #218, because at this point it would probably not be wise to parse uploaded file ourselves. But I suppose I could rebase without #218 if that's a problem for you.
It should be a solution for #178 (and folkloreinc/laravel-graphql#125)
I'll write some docs, once we agree on the code.