Optimizing API Queries for Reading Column Contents of an Item with Various Field Types

Hello Monday API Community,

I’m currently working on a project where I need to retrieve the contents of all columns of a specific item, including various field types such as mirror and connected boards. My current approach involves making at least three separate API queries, but I’m wondering if there’s a more efficient way to accomplish this.

First Query: I start with a basic query to fetch the dataset, like so:

query {
  items (ids: XXXXXXX) {
    name,
    column_values {
      column { id title }
      id
      type
      text
      value
    }
  }
}

  • However, this returns null or empty values for mirrored or connected fields.
  • Second Query: To retrieve mirrored field values, I use:
query {
  items (ids:XXXXXXXXX) {
    column_values {
      ... on MirrorValue {
        id
        display_value
        text
        value
      }
    }
  }
}

Third Query**: Finally, for connected board fields, I query:

query {
  items (ids:XXXXXXXXX) {
    column_values {
      ... on BoardRelationValue {
        id
        display_value
      }
    }
  }
}

My Question: Is this the best approach to access all field contents of an item? Sending three separate queries to fetch data from a single dataset seems inefficient, and I can’t help but feel there might be a better method that I’m overlooking. Could any experienced Monday developers advise if there’s a more efficient way to achieve this?

Thank you for your guidance!

The fragments are only evaluated on the specified column type. so ... on MirrorValue means its only evaluated on column_value of the type MirrorValue. This means you can list many ColumnValue fragments

Since some of the fields listed are the same don’t duplicate them within the fragments and only supply the unique fields.

query ($itemId: ID!, $columnIds: [String!]) {
  items(ids: [$itemId]) {
    name
    column_values(ids: $columnIds) {
      column {
        id
        title
      }
      id
      type
      text
      value
      ... on MirrorValue {
        display_value
      }
      ... on BoardRelationValue {
        display_value
      }
    }
  }
}
2 Likes

Hi @codyfrisch, that takes me a lot further. Thank you

2 Likes