New to GraphQL and struggling

I ran this query:

{
  boards(ids: my-board-id) {
    columns {
      id
      title
    }
  }
}

As expected, that gave me a list of columns with their id & title.

Among those columns are:

          {
            "id": "name",
            "title": "Name"
          },
            "id": "contact_phone",
            "title": "Phone"
          },
          {
            "id": "contact_email",
            "title": "Email"
          },

I assumed I could then run a query like:

{
  boards(ids: my-board-id) {
    items_page {
      items {
        name
        contact_phone
        contact_email
      }
    }
  }
}

But it tells me I cannot query “contact_phone” and “contact_email” on type item.

So I have no idea how to retrieve the contact’s name, email, and phone from that board. I’ve spent the last couple hours looking through the documentation but can’t find anything, so here I am.

Thanks in advance.

The name is an item level field, the rest are column_values and need to be retrieved as such. It is annoying that name cannot be retrieved as a column_value despite being returned in a columns query on the board.

I am using column type fragments to expedite getting the data, but the value key on a column_value is a JSON serialized form of the column’s value. The fragment ... on EmailValue only executes on columns that are of the type email for example, so will return those additional fields.

Pass the column IDs you want in an array to the ids argument of column_values. Always return your ID for boads, items, columns, updates, etc. when querying or else you’ll have no idea which is which.

{
  boards(ids: my-board-id) {
    id
    items_page {
      items {
        id
        name
        column_values (ids: ["contact_phone", "contact_email"]) {
          id
          text
          value
          type
          ... on EmailValue {
            email
            label
          }
          ... on PhoneValue {
            phone
            country_short_name
          }
        }
      }
    }
  }
}
1 Like

Ah! This points me in the right direction. Thanks!

1 Like

I forgot to mention, if you don’t pass any column Ids to to column_values it will return all columns.

1 Like

Good to know. I doubt I’ll ever use it like that, but it’s nice to know it’s there if I need it.

1 Like