Skip to content

Feature: support standard GQL upload requests #296

@timmywil

Description

@timmywil

Absinthe currently expects something like:

curl localhost:4000/graphql
  -F query="mutation { uploadFile(users: \"users_csv\") }" \
  -F [email protected]

But, the graphql multipart request spec, used not only by Apollo but all other GQL servers these days, instead defines the following format:

curl localhost:4000/graphql \
  -F operations='{ "query": "mutation ($file: Upload!) { singleUpload(file: $file) { id } }", "variables": { "file": null } }' \
  -F map='{ "0": ["variables.file"] }' \
  -F [email protected]

While the latter may seem longer, it's actually simpler as the operation can be parsed in much the same way as normal GQL mutations. It's also worth noting additional variables are handled very differently.

While the Absinthe docs for File Uploads does provide a solution for Apollo by linking to apollo-absinthe-upload-link, that code has not been touched in 5 years and no longer works reliably.

In comparison, the spec linked above has time-tested and maintained implementations not only for Apollo, but several other clients and servers. I am currently building a Flutter app, for which there is no Absinthe-compatible solution and I'll likely end up having to write my own GQL link.

This issue is simply a feature request to support the format that everyone else is using for uploads. You would not only be able to recommend Absinthe to those not using Apollo, you would no longer need to recommend an unmaintained, custom apollo link. The existing GQL links would just work.

Thanks for your time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions