Search code examples
filegraphqluploadpostman

Is there any way to upload files via postman into a GraphQL API?


Currently I'm using Altair to upload files (in my case it's just for images) to my GraphQL API. However, all my other routes are stored in postman and it'd be nice if I could use just one application - Postman - for everything.

In Altair I can simply select an image and store that as a variable that I put as the value for my GraphQL Upload field.

Does anyone know if Postman supports that (or a similiar) feature?

Thank you!


Solution

  • You can use Form-Data to do this.

    Key: Operations (this is for the query / mutation )

    {"query":"mutation updateAvatar($avatar:Upload!) {\n  updateAvatar(avatar: $avatar)\n}"}
    

    Key: map ( this is to map the files to your query / mutation )

    {"0": ["variables.avatar"]}
    

    Key: 0 ( upload your image/file etc )

    postman