Hello there @wriley and welcome to the community!
I hope you like it here 💪
You can use a mutation like this one:
mutation {
change_multiple_column_values(item_id:9876543210, board_id:1234567890, column_values: "{\\"people\\" : {\\"personsAndTeams\\":[{\\"id\\":4616627,\\"kind\\":\\"person\\"},{\\"id\\":4616666,\\"kind\\":\\"person\\"},{\\"id\\":51166,\\"kind\\":\\"team\\"}]}}") {
id
}
}
I hope that helps!
Cheers,
Matias
You need to pass the object that is the value through JSON.stringify()
first to turn it into a JSON string.
While a GraphQL query looks a lot like Javascript, is it not, it is actually just a string. In the change_column_value
the value
field takes a string (or an object that has been stringified) not an object as you tried.
Below uses GraphQL variables. They are defined in parenthesis after the word mutation in the query string, and then you can use them in the rest of the mutation. These are preferred to trying to build a string since some oddities can happen with string manipulation that won’t happen if the query is fixed.
Below is some example javascript around this:
const query = "mutation($boardId: Int!, $itemId: Int!, $columnId: String!, $value: JSON!) { change_column_value(board_id: $boardId, item_id: $itemId, column_id: $columnId, value: $value){id}}"
const variables = {
boardId: 111111111,
itemId: 2222222,
columnId: "multiple_persons1"
value: JSON.stringify({personsAndTeams: : {id: 12345, kind: “team”}, {id: 678910, kind: “team”}]})};
const response = await monday.api(query, {variables});
//the monday.api method JSON.stringify()s as below to build the request body sent to the server. You don't need to do this part, its done for you.
//const requestBody = JSON.stringify({query, variables})