-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Add an ability to upload files #84
Comments
Hey @ssbb, thank you for opening the issue! It looks like both the Absinthe and multipart-request-spec use a Scalar type called module Swapi.Scalar exposing (..)
# ...
type Upload
= Upload String module Query exposing (..)
# ...
type alias SendFileRequiredArguments =
{ file : Swapi.Scalar.Upload }
sendFile : SendFileRequiredArguments -> Field String RootQuery
sendFile requiredArgs =
Object.fieldDecoder "sendFile" [ Argument.required "file" requiredArgs.file (\(Swapi.Scalar.Upload raw) -> Encode.string raw) ] Decode.string Given that this is treated like a special type, it seems like it would be nice to treat this scalar as a special thing and require a file to be passed in here. So the generated code could just change the underlying type of the scalar type Upload
= Upload File The Encode module would then have to take on some more complexity, doing more than just turning it into a simple GraphQL query... instead, it would have to encode the files as But I think that it's worth experimenting with that approach. Just adding a What do you think? |
Hi @dillonkearns, thanks for quick detailed reply 👍 I am not sure it's good idea to rely on My idea was to give a bit more control over HTTP request. Files can be not related to GraphQL at all, right? Like you sending normal GraphQL query and files at the same time (w/o affecting query with things like BTW graphql-multipart-request-spec using a bit different approach - request should contain |
A small bump to this issue as I ran into it today with a I had to bypass |
Hey @pdamoc , the last I checked file uploads weren't part of the spec in a concrete and standardized way, so I'm actually not sure there a clear and actionable thing that can be done here that follows a the spec. |
It will be good to add something like
withFiles : List ( String, File.File ) -> Request decodesTo -> Request decodesTo
so it will be possible to upload files alongside with query.It will require to send request as POST with
multipart/form-data
though so it will overwrite things likeQueryRequestMethod
silently.Sending files over GraphQL is not a part of official spec but supported by many frameworks:
The text was updated successfully, but these errors were encountered: