Now I want to query the items that I created as the code below to get item name, firstname, lastname etc.
$query = ' query{ items { id name firstname lastname } }';
Here is the error it displays
{"errors":[{"message":"Field 'firstname' doesn't exist on type 'Item'","locations":[{"line":1,"column":26}],"fields":["query","items","firstname"]},{"message":"Field 'lastname' doesn't exist on type 'Item'","locations":[{"line":1,"column":36}],"fields":["query","items","lastname"]}],"account_id":66xxxx}
With just some small tweaks, we can get this query working.
Column names are not fields that can be used to query items. Instead, we can make queries with column values to achieve the same result.
The issue with this query specifically is that firstname and lastname are not fields that can be used in the items query. (See Item query fields: Items)
In order to get column data, you can pass the column_values field with the ids argument to specify the exact columns you’d like to return using the column ID. (See Column Values query fields: Column Values)
Be sure to also include the boards field in your query, as it will make your call more specific.
This query will work instead:
query {
boards (ids: 1234567890) {
items {
id
name
column_values (ids: ["examplecolumnID", "examplecolumnID"]) {
title
value
}
}
}
}