1

I want to upload large files to my backend which I created with gqlgen.

To do that, I want to use multipart requests to keep only one endpoint. (Client implementation e.g. apollo-upload-client)

There is an example and documentation on how to upload files using gqlgen using multipart requests. However, this only works for small files. When I try to upload large files (only 500mb in this case) I get a connection reset error. (I get the same error in my implementation and the example gqlgen provided)

Does anyone know a solution for this?

Gianluca Filitz
  • 371
  • 1
  • 2
  • 10

1 Answers1

0

I have kind of the same problem. I want to upload multiple files using multipart which in total cant be more than ~30MB. I found this in the gqlgen docu (https://github.com/99designs/gqlgen/blob/master/docs/content/reference/file-upload.md#Configuration)

There are two specific options that can be configured for uploading files:

  • uploadMaxSize This option specifies the maximum number of bytes used to parse a request body as multipart/form-data.

  • uploadMaxMemory This option specifies the maximum number of bytes used to parse a request body as multipart/form-data in memory, with the remainder stored on disk in temporary files.

However. I have no idea how to actually aply these configs. Maybe you can do something with this info.

stukoi
  • 33
  • 4
  • 1
    I do know how to apply these settings. You have to specify them in the multipart transport (see https://github.com/99designs/gqlgen/issues/1631). But just like in that issue, this did not change anything for me. Maybe it helps you. I ended up implementing a separate endpoint. – Gianluca Filitz Mar 06 '23 at 07:29
  • Hey, @GianlucaFilitz, thank you for your help. Indeed I resolved this problem by just not calling `NewDefaultServer()` but instead `New()` and then manually setting the Transport. This is a workaround described in the Github issue you o´provided. `NewDefaultServer()` alread sets this this Transport and any subsequent tries to set this Transport will not override the intial. I explained it in my comment to the accepted anser in my own question here: https://stackoverflow.com/questions/75646152/set-graphqls-max-file-upload-size-golang – stukoi Mar 06 '23 at 13:56
  • Nice :) Did you test/benchmark this? What are the quantity/ file size limits? How is the memory consumption? How fast is the upload on localhost? – Gianluca Filitz Mar 06 '23 at 17:33
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 10 '23 at 19:19