API - Get a group by its title

Hi, how can I create a GraphQL Query that will return a single Group by its title rather than its id?

I can use the playground to get all Groups and I can also get a single group via its id, but id’s are randomly named and so I want to get a group by its title which I create and thus can control.

I though I’d be able to do something like this …

// fails
{
boards(ids: 000000000) {
groups(title: “nice_title”) {
id
title
}
}
}

but if I’m reading the documentation correctly (API v2 Documentation) then the only thing I can do is this …

// works
{
boards(ids: 000000000) {
groups (ids: “some_random_title”) {
id
title
}
}
}

Or get all groups and use code to iterate the groups to find the one I want …

// works - gets all groups for my board
{
boards(ids: 000000000) {
groups {
id
title
}
}
}

I would prefer not to do this for performance reasons.

I’m certainly no GraphQL expert so any help is appreciate, Thanks!!!

Hello russ,

I’ve run into similar issues with the API. For something like this, you are unfortunately going to have to make 2 queries or you can get all the board items and get the groups all in one query then iterate through the groups until you get the id of the group you want then parse out the items in that group. Below is an example of what I’m talking about. This way at least you get all the groups and items in 1 GraphQL query then just have to iterate through them on the client.

{
boards(ids: 000000000) {
groups {
id
title
}
items {
group {
id
}
}
}
}

Hi Donald, thanks so much for the prompt reply. I suspected as much but all good. I will retrieve all groups and iterate locally to find the one I want from the list.
Thanks!