How to define operations map in POSTMAN for GraphQL file upload

How to define operations map in POSTMAN for GraphQL file upload


1

This is what my schema looks like:

extend type Mutation {
    createMutation(
      my_id: ID!
      my_data: input_data
    ): some_output


input input_data {
    some_key: ID!
    file : Upload!
}

This is how I am defining my operations in POSTMAN

{
  "query": "mutation CreateMutation($my_id: ID! , $my_data: [input_data]) { createMutation(my_id: $my_id, my_data : $my_data) {   some_key}}",
  "variables": {
    "my_id": "some-string-id",
    "my_data": [
      {
        "some_key": 123,
        "file" : null
      }
    ]
  }
}

under map I have : { "0" : ["variables.file"] }

I map 0: file_from_local.png

How to define operations map in POSTMAN for GraphQL file upload

The server recieves file = null, what am I doing wrong? How can I replace this

2 Answers
2


1

Updating map to { "0" : ["variables.my_data.0.file"] } fixed it

1

  • Thank you for this update. It's solved my problem as well

    – Alex Lance

    Jul 1, 2022 at 12:23



0

Operations:
{"query": "mutation ($profilePicture:Upload!) {updateProfilePicture(profilePicture: $profilePicture ) { done ,errors { field message } }} ",
"variables": {
"profilePicture": null
}
}

map:
{ "1": ["variables.profilePicture"] }

1:
file.jpg

Hi Sid, How to write graphql query for above postman upload query pls help.



Leave a Reply

Your email address will not be published. Required fields are marked *