mercurius-js / mercurius-gateway

Mercurius federation support plugin

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Federation File Upload

HashDot opened this issue · comments

Hi, I try to upload files with a federation but it does not work. I tried various examples and without a federation it is working smoothly. In the case of the federation I get an error and I have tried to debugging it but I have no plan where it comes from.

I think it is a wrong payload from the gateway? If it were only the file payload I think it should work. Has anyone a idea how I can make it work?

Response:

{
  "data": {
    "uploadImage": null
  },
  "errors": [
    {
      "message": "Variable \"$file\" got invalid value { promise: {}, file: { filename: \"logogreen.png\", mimetype: \"image/png\", encoding: \"7bit\" } }; Upload value invalid.",
      "locations": [
        {
          "line": 1,
          "column": 28
        }
      ]
    }
  ]
}

Gist: https://gist.github.com/HashDot/150b8265c2e655ef07be24d7531db5bd

I have a feeling this is not supported right now.

Okay thats a problem for me. I can help to implement this feature. So that I can help, can you give me a hint where I can start?

I would:

  1. study how graphql-upload works
  2. study how the gateway works and how we forward data to the target microservices
  3. add some logic to convert a normal request to a multipart request if the target microservice use the upload scalar, forwarding all the needed parts.

It's a complex feature and it likely won't scale well, as it accumulates files in memory. I would recommend to use a direct upload to AWS S3 instead of passing it to graphql.

Don't know whether it is helpful, but maybe inspiration can be drawn from this: https://github.com/profusion/apollo-federation-file-upload

@HashDot are you still considering to implement this feature?

any news on this?