What’s the best way to optimize GraphQL queries for handling deeply nested board structures?

Hi everyone,

I’m working with Monday’s GraphQL API and need some guidance on structuring queries for complex board structures. When dealing with multiple layers of data—like boards, groups, items, subitems, and column values—my queries sometimes feel inefficient or return more data than needed.

What’s the best way to optimize GraphQL queries for handling deeply nested board structures? Are there any best practices to avoid performance issues while ensuring I retrieve all necessary data?

Would love to hear any recommendations or insights from those who have tackled this before! Thanks in advance.

hey @MarcusTaylor

Bill here from monday.com - welcome to the community! :wave:

As a general suggestion, we recommend using the query arguments to provide specific IDs and only query what you know you need and also to use the limits and paginate through the responses.

Nesting multiple queries also increases the complexity of the query so we also recommend avoiding nesting too many queries together.

Cheers,
Bill

Something else to remember is nesting can cause exponential growth.

One common solution though is to get the items of a board, and in the item return the group - rather than try to get groups in boards and return the items from the group. Massive difference in calculated complexity.

Another thing to do is on the board, is to get the column of the type “subtasks”, this is your subitem column. The settings_str of that will contain the board ID that is the subitem board. Now while you iterate your items from the board, you can do a second query on the subitems board. Those items you return from the subitem board include the parent_item {id} for them. Unlike the subitems on an item - which is not deterministic in size (hence it treats it as though there are 1000 subitems) getting the parent is always one item.

Now you have an array of your items with their groups, and all your subitems with their parent. You can then reorganize everything back together into a board=>groups=>items=>subitems structure.

This method is just two iterations of a board with almost no extra depth and no exponential growth in complexity.