Closed coryodaniel closed 6 years ago
Looking at the http requests coming into absinthe/plug ...
Here is the one that works (from curl):
file
body param is loaded by plugfile
variable%Plug.Conn{
body_params: %{
"file" => %Plug.Upload{
content_type: "image/jpeg",
filename: "pants.jpg",
path: "/var/folders/x3/yf3cmyj54mn_59qh3xcyl3wc0000gn/T//plug-1541/multipart-1541180969-847941438387443-1"
},
"query" => "mutation{uploadPhoto(productId: \"d50e25b0-387a-44ad-98b0-cd0265cefda0\", file: \"file\"){id,url(version: ORIGINAL)}}"
},
params: %{
"file" => %Plug.Upload{
content_type: "image/jpeg",
filename: "ruins.jpg",
path: "/var/folders/x3/yf3cmyj54mn_59qh3xcyl3wc0000gn/T//plug-1541/multipart-1541180969-847941438387443-1"
},
"query" => "mutation{uploadPhoto(productId: \"d50e25b0-387a-44ad-98b0-cd0265cefda0\", file: \"file\"){id,url(version: ORIGINAL)}}"
},
req_headers: [
{"host", "localhost:8088"},
{"user-agent", "curl/7.54.0"},
{"accept", "*/*"},
{"content-length", "795873"},
{"expect", "100-continue"},
{"content-type",
"multipart/form-data; boundary=------------------------949cb840cd576ddd"}
]
}
Here is the request from React Native that fails:
file
comes through as a variable with the literal value "file"
%Plug.Conn{
body_params: %{
"query" => "mutation uploadPhoto($file: Upload!) {\n uploadPhoto(productId: \"d50e25b0-387a-44ad-98b0-cd0265cefda0\", file: $file) {\n id\n url(version: \"ORIGINAL\")\n __typename\n }\n}\n",
"variables" => "{\"file\":\"file\"}"
},
params: %{
"query" => "mutation uploadPhoto($file: Upload!) {\n uploadPhoto(productId: \"d50e25b0-387a-44ad-98b0-cd0265cefda0\", file: $file) {\n id\n url(version: \"ORIGINAL\")\n __typename\n }\n}\n",
"variables" => "{\"file\":\"file\"}"
},
req_headers: [
{"host", "localhost:8088"},
{"content-type",
"multipart/form-data; boundary=ECv.0QQlvvCy0Sy9Gi7KfTrrO1N0BkXj_AQL5k6kW20cLl7.5OvzjQloA0_pVumS4qDEza"},
{"user-agent", "Expo/2.5.9.1014764 CFNetwork/897.15 Darwin/17.4.0"},
{"accept", "*/*"},
{"accept-language", "en-us"},
{"content-length", "3834787"},
{"accept-encoding", "br, gzip, deflate"},
]
}
Turns out both ways work :D Had a syntax error w/ Enum in Apollo :(
I currently have an absinthe graphql api that will accept uploads (from curl). I'm now trying to upload from react native and can't seem to figure out how to do it.
Using the following curl command, I can successfully upload files:
Output from elixir - which looked strange to me because the file is a string literal "file" ... but it works
Below is the react component that gets an error back:
It looks as though the
ReactNativeFile
is getting serialized to"file"
in the variables map, but the file does actually get submitted (I can see it in wireshark)Thanks in advance for any guidance! :D