I'm trying to upload an image with a graphql mutation to my server, how can I test this with insomnia.rest? the the Structured request for a Graphql Query doesn't show any field to add a file. Also, if this isn't posible with insomnia, what other alternative can I use to test something like this?
Asked
Active
Viewed 7,650 times
7
-
`apollo-upload-client` is a client alternative – Mark Chackerian Apr 02 '18 at 15:22
-
where can I find examples of how to implement a client, I'm very new to react so I don't find their readme very clear – sgaseretto Apr 03 '18 at 18:34
1 Answers
13
You'll want to use the "Multipart" request type. Then add the following values:
operations
: The graphql mutation in the format that is sent in the request, which should look something like below. (You can get this by using the GraphQL request option and switching to multipart form and then moving the values around).
{
"query":"mutation UploadFile($file: File!) {\n addResearch(file: $file)\n}",
"variables":{ "file": null},
"operationName":"UploadFile"
}
map
:{ "File": ["variables.file"] }
File
: The file to upload. Click the dropdown on right beside the value input and choose "File" so that you can select a file.

SimplyComplexable
- 1,116
- 11
- 19
-
How about byte array? I am trying to pass in a byte array to a mutation. https://stackoverflow.com/questions/57446927/how-to-send-byte-array-to-graphql-mutation – angelokh Aug 11 '19 at 02:50
-
1Do you just have the array that you need to pass in? Or is it a blob or something? – SimplyComplexable Aug 12 '19 at 22:45
-
-
@SimplyComplexable: (newbie here)I dont get it, can u please provide images? – Sushilzzz Nov 14 '19 at 07:52
-
@Sushilzzz I just edited the example with an image. The image is a little different but should illustrate what what you're trying to do. – SimplyComplexable Nov 14 '19 at 21:31
-
@SimplyComplexable an image different than the example is more confusing – francisco Oct 26 '22 at 10:42