Absinthe: I get "no query document supplied" when uploading a file

I got this same error both when using the Altair Graphql Client, and when sending it from Flutter package: graphql_flutter. The interesting thing is they both formatted the request the same, which is slightly different from a normal graphql request.

Here are my parameters with no files. This works fine:

  Parameters: %{
"operationName" => "CreateMessage", 
"query" => "mutation CreateMessage($input: CreateMessageInput!) {\n  createMessage(input: $input) {\n    id\n  }\n}", 
"variables" => %{"input" => %{"chatId" => "8a71cedc-03a0-410d-99d6-4ff6b82dc05b", "files" => nil, "text" => "msg"}}}

When I add a file on the client side, here are my parameters:

  Parameters: %{
"0" => %Plug.Upload{content_type: "image/jpeg", filename: "scaled_8f9a1d58-13fc-4c38-89c6-86c5b403dbf77423953871665859387.jpg", path: "/var/folders/z5/svc48qxx4lv128w2g_9vmqrh0000gn/T//plug-1609/multipart-1609986093-345070228716158-4"}, 
"map" => "{\"0\":[\"variables.input.files.0\"]}", 
"operations" => "{\"operationName\":\"CreateMessage\",\"variables\":{\"input\":{\"text\":\"with File\",\"chatId\":\"8a71cedc-03a0-410d-99d6-4ff6b82dc05b\",\"files\":[null]}},\"query\":\"mutation CreateMessage($input: CreateMessageInput!) {\\n  createMessage(input: $input) {\\n    id\\n  }\\n}\"}"}

It looks like it’s using this format: https://github.com/jaydenseric/graphql-multipart-request-spec. However Absinthe returns a “No query document supplied” error. Is there anyway to get this to work? Can I add some plug that formats the request in a way that Absinthe can recognize?

2 Likes