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?
To upload a video using Insomnia, you have to set the body as multipart and add the file and all the other necessary parameters. The upload[file] parameter needs to be changed to type 'File' using the small arrow at the right side of the row. The Multipart body should look similar to the sample image.
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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With