Add field "isEmpty" and "itemCount" to Group in API

Hello,

Currently, if we want to check if a group has no item, we need to perform this GraphQL query:

query {
  boards (ids: [xxxxxx]) {
    groups  {
      items_page (limit: 1) {
        cursor
        items {
          id
        }
      }
    }
  }
}

It requests one item in each board group. If no item returned, the group is empty. The main drawback of this query is its complexity cost :

"complexity": {
    "before": 5000000,
    "after": 1986980,
    "query": 3013020
  }

3013020 in complexity (with 1, 5, 20, x groups - it’s always the same complexity is way to much to only check if a group is empty. And imagine, if I want to compute the number of items in each group…

So the request is:

  • add a field isEmpty in the Group object to avoid this type of complex query
  • add a field itemCount in the Group object for the same reason

Regards

Hello there @clement.devdevils,

What about using something like this?

{
  boards(ids: 1234567890) {
    groups(ids: "new_group1") {
      items_page {
        items {
          name
        }
      }
    }
  }
}

If it is empty, then you have no items in that group.

The query costs 3080 complexity points.

If you need to check the ID first, you can use:

  boards(ids: 1234567890) {
    groups {
      id
      title
    }
  }
}

This one costs 2020 complexity points.

What do you think?

Looking forward to hearing from you!

Cheers,
Matias

I guess the question is: why is not specifying the groupId 1.000 times more expensive then querying the items in a group specified by it’s groupId.

1 Like

What about using something like this?

I currently use this as a workaround for many group. But as the number of group increase, the time to execute the query, which is not user friendly.

(Also, it doesn’t apply to the itemCount issue)

I guess the question is: why is not specifying the groupId 1.000 times more expensive then querying the items in a group specified by it’s groupId.

Indeed, doesn’t seem really logical.

In my opnion, requesting these two information should not destroy our complexity budget, since it’s something that can be computed and stored by monday.com backend

Especially since the item_count is a property on the board already.

1 Like

Hello everyone!

Thank you for the explanations and the feedback!

People reading this: You can vote for this at the top left corner of this screen :grin: