Retrieve an item by specifying its itemId

hi Devs,
I am stuck. I know my boardId and I know my itemId.
Using the api, I would like to retrieve the item from the board using the boardId and the itemId.
I cannot figure it out.

I can use a different column on the item and use that to retrieve the specific item (graphql api using items_page_by_column_values) - no probs.

However, I feel it must be faster to retrieve the information by specifying the boardId and the itemId but I cannot figure it out.
My intial thought was to do something like this:
query = ‘’’
{
boards(ids: %s) {
name
id
items_page (limit:%s) {
cursor
items (ids: “%s”) {
id
name
column_values {
id
type
value
text
column {
title
}
}
}
}
}
}
‘’’ % (boardId, maxLimit, itemId)

but the ‘ids’ is not allowed on the ‘items’.

I tried to use items_page_by_column_values but it does not recognise “id” as a column name.

Any help/ideas appreciated?

thanks loads,
Kevin

Hi @caoimhinmacg

The ids argument need to go to items_page (not to items). There is a faster way to achieve this as you don’t need the boardId when querying just one item.

Like:

query {
  items(ids: 123456789) {
    column_values {
      id
      value
      type
      text
      column {
        title
      }
    }
  }
}

Don’t forget that some column types do not return value and text without explicitly asking for it with fragments inside the column_values, like ...on MirrorValue{id value display_value}

3 Likes

The reason they say boards is faster is that when you use items_page you can get up to 500 items at a time from the single board.

If you use items as the root, and are specifying the item IDs, you are limited to 100 items at a time. So you’d need to make more queries, which is obviously slower - assuming you have that many IDs to get!

BUT if you already have one item ID, just using the items root query is actually faster than boards because the resolver doesn’t have to resolve the board first. Plus, the API complexity score is lower this way too.

1 Like

thanks a million folks - apologies - thought I had replied earlier!