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

1

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

1 Comment

{ "errors": [ { "message": "No query document supplied" } ] } I get the following error on trying it out this way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.