Skip to main content

The column values are updated successfully when I run the following mutations in Playground. But when called in code, these same mutations throw Graphql Validation errors. All board scope permissions are set.




works in playground ☑️


graphql-1        graphql-2




doesn’t work in code ❌


const query1 = `mutation {
change_column_value (board_id: 726291451, item_id: 726291453, column_id: "status", value: "{\\"index\\": 1}") {id}}`

const query2 = `mutation { change_multiple_column_values (board_id: 726291451, item_id: 726291453, column_values: "{\\"url\\":\\"urlVal0\\",\\"name1\\":\\"nameVal0\\"}") {id}}`


// also no good
const val = {"index": 1};
const query = `mutation {
change_column_value (board_id: 726291451, item_id: 726291453, column_id: "status", value: ${JSON.stringify(val)}) {id}}`

Hey @supernova ,


remove the curly braces after “mutation”.


Tell me if that helped


Greetings


const query = 

`mutation change_column($value: JSON!) {

change_column_value(board_id: 726291451, item_id: 726291453, column_id: "status", value: $value) {
id
}

}`;

const value = { "value": "{\\"index\\": 1}"};


And this should work also, if I’m not mistaken.


Hey @supernova!


Phew! You found a bug!!


I tried it myself and I got the same problem error.

If you want it working, you have to use variables, unfortunately. Here’s how I have it working:


      const query = `mutation changeValues($board_id: Int!, $item_id: Int, $column_id: String!, $value: JSON!) {
change_column_value (board_id: $board_id, item_id: $item_id , column_id: $column_id, value: $value) {
id
}
}`

monday.api(query, {variables: {"board_id": boardId, "item_id": itemId, "column_id": "status", "value": "{\\"index\\": 1}"}}).then((res) => console.log(res)).catch((e) => console.log(e))



Hope that helps.


You got it 🌶 !! This works yay you’ve helped A LOT 👍 👍 💯


Hi @TMNXT-Dev , I tried both ways that you suggested, but they didn’t work for me. However, @pepperaddict’s solution of using variables worked! I just checked monday’s API doc & now I see that using variables is specified. Just something that I skipped over… ( nothing crucial /s )


Hey @supernova 👋


I’m so glad that you’ve found a working solution in the community here!


@pepperaddict a plate of chillis to this very helpful man! Jokes aside, thanks so much for helping out here!


@TMNXT-Dev thanks for chiming in as well 🙂


@supernova


You can definitely disregard this completely since you’ve got this to work already 🙂


That said, I do see one more thing that sticks out to me in the queries you are sending:


“{"url":"urlVal0","name1":"nameVal0"}”


To my mind, that should be formatted as such instead:


{“url”: “http://monday.com”, “text”: “go to monday!”}


Do you think that could be part of what was causing the errors before?


-Alex


Hi @AlexSavchuk , I don’t think so cause for this test case “url” & “name1” are the column IDs & url col is type “text” so the value can be any string - doesn’t have to be url string


Nice solution @pepperaddict !


Thank you!


@supernova


Thank you for getting back to me on this! Ah, I had assumed that the “URL” key was meant to update a Link column and not a text column. Thank you for clarifying further!


@TMNXT-Dev thanks for spreading the good vibes 🙂


-Alex


Actually, I didn’t realize monday supported Link columns. Thanks to your comment @AlexSavchuk I just discovered a bunch of other column types! Pleasantly surprised by all the options available 😲