GraphQL - how can I get data from all groups except for one?

I’m trying to use GraphQL and export from a specific board all data ( group name,id, items, columns values ) except for a specific group and I can’t find a way to do that in a query. the query I use is:

query {
    boards (ids: 1512837503) {
        groups {
            title
            id
    items(limit:100) {
    name
      column_values {
        value
        text
        title
      }
        }
    }
}
}

The output is too large and I don’t need the data in a specific group. Is there a way to add an exception of one group?

Thanks!

Hi @helly,

Welcome to the community! :smiley:

groups only accepts one argument that allows you to return data from specific group IDs. You could essentially try your request in reverse - add all group IDs except for the one you don’t need data from.

2 Likes

Hi Rachel,

Would you be able to provide an example query that takes in a single group ID. I have a board with 12 groups and would like to target a single group for performance efficiency but I cannot figure out how to add any group id filtering on the query without an error being thrown.

Hi @Jmiller1,

You could use a query like the one below!

query {
  boards (ids: 2973338169) {
    groups (ids: "group_title") {
      items_page {
        items {
          id
          name
        }
      }
    }
  }
}

Let me know if this helps!

Best,
Rachel

1 Like

Hi Rachel,

Thank you for the response, but after spending a lot of time looking into this I don’t believe it is possible to filter by groups as part of the query. I’ve only been able to get calls to not error out when group data is included, but I have the then filter by it on my side to get to the select items needed.

Not sure if this is a path for new ideas, but it would be very useful if groups could be used to filter when doing a query/call so I don’t have to pull 5,000 rows to access 10.

Jack,

Can you post the queries that error, and the errors? This kind of information helps a lot in either spotting the fix, or getting monday to fix the issue.

1 Like

The first picture shows all groups on a board and I have underlined the one I am trying to target with a query. I’ve added a picture on the groups minimized on the board to see visually.

Next picture is the query as suggested by Rachel:

This picture is a query I got to work that included both groups and items, it shows a response with data but the data is not filtered by the group I’m trying to target, it returns much more:

For more context on what I am currently using is a python library also by the name of monday from which I import MondayClient and am able to use this to get the data from this board now, I would like to shift away from it so I don’t have to use pagination.

Hi Rachel, I’m not sure if you get notifications on a thread when I reply to someone else but I provided a response with screenshots and descriptions of my code.

I had tried the code you suggested prior to your suggestion. I agree the documentation reads in a way where that query should work because it says groups have an IDs argument to target a specific group to return. I haven’t been able to find a way for it work though, and have run into other threads online that confirmed the only way to filter by group was to do it locally after pulling all data.

I probably should have explained all that but that’s why I jumped straight to I don’t think it’s possible right now.

I can consistently with API 2023-10 return just items in a group by using a groups(ids: ["group_id"]) with items_page as shown.

From the error it appears you’re still using API 2023-07, not 2023-10 which is required for items_page to work.

Hi @Jmiller1,

I agree with @codyfrisch here! Our default version is 2023-07 because 2023-10 contains many breaking changes. You will have to specify 2023-10 (or later) to get the items_page field. Here are the docs that explain how!

Give this a try and keep us updated.

Best,
Rachel

Ahh thank you both Cody and Rachel, after checking which version I was using it was 2023-07 because I had not stated which type to use.

For anyone who come across this in the future see below:


default is the older version

change it in your headers:
api set up

query originally suggested and as described in the documentation now works as intended:

Love to hear it! Please reach out with any other questions.

Best,
Rachel

1 Like

Wanted to loop back on this query you used in the one that didn’t filter by group as anticipated. This is pretty easy. You are putting items hierarchically under boards not groups see below, how moving just one } from after group.id to after the items changes the whole structure from getting the boards.items to boards.groups.items

{boards(ids: "123123"){groups(ids: "new_group"){title id} items {name}}}

vs

{boards(ids: "123123"){groups(ids: "new_group"){title id items {name}}}}

All that said, definitely stick to 2023-10 or else you’ll be rewriting stuff in less than a month. Okay back to rewriting stuff for me!

I will definitely try to stick to 2023-10. I personally only use the api to get stuff out to manipulate it with python so no additional rewriting for me. I can tell the graph ql type api is a powerful tool, it’s the stuff like you showed with the hierarchy I’ve struggled to interpret from the documentation. Just am not working in the api enough though, I appreciate that tip. Best of luck with the rewriting!

Interesting discussion and all valid points. However the title says:
"GraphQL - how can I get data from all groups except for one?"

And that one is not answered :slight_smile:. I guess the only solution is to retrieve all groupId in one call and then make another call (as suggested )including all the returned groupIds except the one you don’t want.

Hello there!

@basdebruin is correct. That is the way to do this.

1 Like