7

I am trying to use Postman to upload a file to GraphQL.

I know how I can upload a file, however, in my mutation I have to pass a String! together with the Upload!.

I am not sure where I can pass this String! in Postman.

My mutation:

mutation AddBookImageOne($bookId: string, $bookImageOne: Upload!){
  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)
}

I tried to pass bookId in the variables key but I keep getting the error:

"message": "Variable "$bookId" of required type "String!" was not provided.",

I checked this: Graphql mutation to upload file with other fields but they use CURL

"Operations" in postman field is:

{"query":"mutation AddBookImageOne($bookId: String!, $bookImageOne: Upload!){\n  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)\n}"}

enter image description here

Magofoco
  • 5,098
  • 6
  • 35
  • 77
  • 2
    pass variables in the `operations` arg - https://stackoverflow.com/a/62683397/6124657 – xadm Aug 26 '20 at 06:25

1 Answers1

8

SOLVED thanks to @xadm

I had to pass the variables in the operations field like:

{"query":"mutation AddBookImageOne($bookId: String!, $bookImageOne: Upload!){\n  addBookImageOne(bookId: $bookId, bookImageOne: $bookImageOne)\n}", "variables": { "bookImageOne": null, "bookId": "be96934c-d20c-4fad-b4bb-a1165468bad9" } }`

enter image description here

Magofoco
  • 5,098
  • 6
  • 35
  • 77