How can I structure the query parameters a graphQL mutation when one of the fields is an array of objects? When I hard-code the mutation this is valid and works:
mutation{
submitResponse(user: "1234", responses: [{ answerId: "wmtBCWtkSeDs5meBe", selected: false}, { answerId: "wmtBCWtkSeDs5meBz", selected: true}]) {
id
}
}
I can't for the life of me figure out how to pass in query parameters for the responses array of objects. How can I define the type of each field in the object. This is what it would like for the user id and that works fine but I can't figure out the responses piece of it.
mutation submitResponse($user: ID!){
submitResponse(user: $user, responses: [{ answerId: "wmtBCWtkSeDs5meBe", selected: false}, { answerId: "wmtBCWtkSeDs5meBz", selected: true}]) {
id
}
}
Thanks!
I know that the question is old, but maybe someone else needs simple solution.
Set type of
responses
asString!
Then:
In my case in BackEnd I use Python, so receive
responses
in BackEnd and then simply convert JSON (string) to Python's dict, something like: