Query complexity issue for retrieving all the subitems of particular item of the particular group of particular board

We are trying to retrieve items and subitems with hierarchy and it is failing with query complexity issue.
The query is as below:

{
boards(ids: xxxx) {
id
name
groups(ids: xxxx) {
id
title
items(ids: xxxx) {
id
name
subitems(ids: xxxx) {
id
name
}
}
}
}
}

Getting below error:

{
“errors”: [
{
“message”: “Query has complexity of 2001200120022, which exceeds max complexity of 5000000”
}
],
“account_id”: 11771408
}

Currently the instance is having sample data with less than 100 items including all the workspaces.

How we can avoid the issue with query complexity to retrieve the same data as above.

Regards,
Prashanth

2 Likes

@prasmadd

You don’t need the boards or groups queries for the item. Also, the id’s of the subitems are unnecessary unless you are only wanting a specific list.

If you need the board and group info, nest the “subqueries” inside the item:

  items(ids: 123456789) {
    board {
      id
      name
    }
    group {
      id
      title
    }
    name
    subitems {
      id
      name
    }
  }
}

Jim - The Monday Man (YouTube Channel)
Watch Our Latest Video: The ITEM ID column
Contact me directly here: Contact – The Monday Man

1 Like

@JCorrell - Thank you for the inputs.

We are facing same issue with another query mentioned below:

Query:

{
  boards(ids: [1234567890]) {
    groups {
      archived
      color
      deleted
      id
      items {
        created_at
        creator_id
        email
        id
        name
        updated_at
      }
      position
      title
    }
  }
}

Error:

{
  "errors": [
    {
      "message": "Query has complexity of 6016020, which exceeds max complexity of 5000000"
    }
  ],
  "account_id": xxxxxx
}

We tried few things and could see when we remove any two fields from query it works. In this case we removed creator_id and email , sharing working query below:

{
  boards(ids: [1234567890]) {
    groups {
      archived
      color
      deleted
      id
      items {
        created_at
        id
        name
        updated_at
      }
      position
      title
    }
  }
}

Could you please help us know what factors we should consider to know while developing the nested queries.

It would be great help if you can point us to any documentation which will help us understand queries formation better.

@Yash

It would not be exactly the same. But I suspect that by moving the group portion from outside the items to inside that would solve the issue.

With regard to documentation, maybe @Matias.Monday could help here.


Jim - The Monday Man (YouTube Channel)
We Create Custom Solutions
Schedule a 1-on-1 Tutorial Session

Thank you @JCorrell .

@Matias.Monday - Could you please help us on this. Thank you in advance !!!

Hello @Yash!

What Jim says makes sense.

You could use something like this:

{
  boards(ids: [1234567890]) {
    items {
      created_at
      creator_id
      email
      id
      name
      updated_at
      group {
        archived
        color
        deleted
        id
        position
        title
      }
    }
  }
}

What do you think?

@Matias.Monday The query what we use is to return groups under board. So we provide board id and expect groups.
Now regarding the items inside groups, we fetch all the details of groups including complex details. We were trying to understand why it gave us error when we provided more than 4 fields in items.

Hello again @Yash!

The issue with that is that the more nested the query, the greater the complexity points usage.

So you might need to either use this other approach and then do some sorting on your end, or maybe do multiple queries.

The more fields you add into the items, the higher your complexity points usage will be.