Skip to main content

I am currently sending a query and getting the data returned from my board:


const query = `{
boards(ids: ${state.mondayBoardId}) {
groups(){
title
items(limit: 50){
column_values{
text
}
}
}
}
}`

The query returns an array of objects (rows). Each object or row has an array of items (column values).


 [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
1. column_values: Array(9)
1. 0: {text: "ARI"}
2. 1: {text: "Fitzgerald"}
3. 2: {text: "Larry"}
4. 3: {text: "WR"}
5. 4: {text: "11"}
6. 5: {text: "Arizona Cardinals"}
7. 6: {text: "Cardinals"}
8. 7: {text: ""}
9. 8: {text: ""}
10. length: 9
2. 1: {column_values: Array(9)}
3. 2: {column_values: Array(9)}
4. 3: {column_values: Array(9)}
5. 4: {column_values: Array(9)}
6. 5: {column_values: Array(9)}

If I’m referencing a column value I can’t call it out as a key:value pair but instead have to get the value by index. If I for some reason change the order of my columns in a board it will throw off the index value.


Is there a way to flatten the return to get an array of objects each having key:value pairs for each column? Something more like this?


1. Array(34)
1. 0:
1. jerseyNumber: "jerseyNumber"
2. nameFirst: "nameFirst"
3. nameLast: "nameLast"
4. position: "position"
5. teamFullName: "teamFullName"
6. teamMascot: "teamMascot"
7. teamTri: "teamTri"
8. __proto__: Object

2. 1: {teamTri: "ARI", nameLast: "Fitzgerald", nameFirst: "Larry", position: "WR", jerseyNumber: "11", …}
3. 2: {teamTri: "ATL", nameLast: "Jones", nameFirst: "Julio", position: "WR", jerseyNumber: "11", …}
4. 3: {teamTri: "BAL", nameLast: "Harbaugh", nameFirst: "John", position: "COACH", jerseyNumber: "11", …}
5. 4: {teamTri: "BUF", nameLast: "Kromer", nameFirst: "Aaron", position: "COACH", jerseyNumber: "11", …}
6. 5: {teamTri: "CAR", nameLast: "Newton", nameFirst: "Cam", position: "QB", jerseyNumber: "11", …}
7. 6: {teamTri: "CHI", nameLast: "Cutler", nameFirst: "Jay", position: "QB", jerseyNumber: "11", …}
8. 7: {teamTri: "CIN", nameLast: "Green", nameFirst: "A.J.", position: "WR", jerseyNumber: "11", …}
9. 8: {teamTri: "CLE", nameLast: "Greco", nameFirst: "John", position: "DE", jerseyNumber: "11", …}

Hi @sbaden,


Which language are you using?


You may need to create a new array using the data in the format you need.


Hey @sbaden,


You could do something like a for loop to parse through the JSON response and assign the values to a dictionary in Python. For example, if you’re trying to get a list of teams:


board_list = =]
for t in parsed_json n'data']''boards']''groups']''title']''items']''column_values']:
board_list.append(int(t('text']))

The API can accept back dictionary values if you declare the variable accordingly with something like eInt!] as your variable declaration.


Hope this helps!


It seems to require multiple passes to get a flat usable set of current column values by column name using GraphQL API.


A secondary issue is you may want the “key” to be the column title - the query syntax appears to only allow access by column ID (internal value).


I was able to do something similar in 3 parts (in Zapier)



  1. Get the columns for the board


{
boards(ids: {{94553960__event__boardId}}) {
owner {
id
}
columns {
title
type
id
}
}
}


  1. In JavaScript make a key:value pair of column title and name


output = {};
inputData.columnTitles.split(',').forEach((key, i) => outputtkey] = inputData.columnIds.split(',')'i]);


  1. Use the output of that to get a specific column value by its ID from the previous step


{ items(ids: d{{94553960__event__pulseId}}]) { column_values(ids:i"{{94574036__Bug Ref}}"]) { text } } }

You could maybe loop through something similar to step 3 for all columns in a keyvalue pair (maybe using a similar syntax to the JavaScript above.


I’m interested to see if you are able to make this work so please provide an update if you have advanced this. Thanks!