API 2023-10 "Column" object ID type mismatch with ids argument

Queries of the “column” field on “boards” take the argument of boards(columns(ids: [String!])) however the Column object id field is of type ID! according to the schema.

while its essentially moot, since ID in a column is always a string. But inconsistencies like this make writing queries using variables a bit more painful since all IDs should be of type ID including when used as arguments (as is the case for boards(ids: [ID!]))

of course someone will gripe that fixing this will create a breaking change in the next API where queries need to get updated…

1 Like

Hi @codyfrisch,

Thanks so much for bringing this up - this feedback is very useful!

I’ve shared it with our API team :smiley:

Best,
Rachel

1 Like

This is not the way variables are used in GraphQL.

each argument in GraphQL accepts a single variable. You are trying to combine variables into an array within the query string which is not possible. For the items are using the ID type name as a variable name. The first part after the word query is the definition of variables $itemId and its type - a non nullable array of IDs [ID!].

const query = `query($itemId: [ID!], $columnIDs: [String]) {
      items(ids: $itemId) {
        column_values(ids: $columnIds) {
          value
        }
      }
    }`

the variables must be:

const variables = {
   itemId: [ID],
   columnIds: [typeColumnId, statusId]
}
1 Like

I tried that way but it didn’t work.

What I’m finding strange is that I have another function that works correctly, with the same structure.

const getDatesValue = async (token, itemId, startColumnId, endColumnId) => {
  // Used in Dates To timeline
  try {
    const mondayClient = initMondayClient();
    mondayClient.setToken(token);

    const query = `query($itemId: ID, $startColumnId: String, $endColumnId: String) {
  items(ids: [$itemId]) {
    column_values(ids: [$startColumnId, $endColumnId]) {
      value
    }
  }
}
`;
    const variables = { startColumnId, endColumnId, itemId };

    const response = await mondayClient.api(query, { variables });
    console.log ('response timeline:', response);
    if (response.data.items[0].column_values[0].value !== null && response.data.items[0].column_values[1].value !== null) {
    return response;
    }
  } catch (err) {
    console.error(err);
  }
};```

Well in your original query you are using [$ID] as a variable for items, when there is no variable $ID defined - there is a variable $itemId defined like in the second one, which you are using correctly there but not in the first query.

You are referencing a variable that doesn’t exist and defining a variable that isn’t used in the first query you asked about.

Also, just for reference, this thread was about the argument type of colum_values(ids: [String] mismatching with the type of column IDs (ID). This is not directly related to the issue you were having. This really should have been a new thread instead of threadjacking the original thread.

1 Like

Hello there,

Let’s please continue this in this topic :grin:

1 Like