Skip to main content

Queries of the “column” field on “boards” take the argument of boards(columns(ids: nString!])) 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: dID!]))


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

Hi @anon29275264,


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


I’ve shared it with our API team 😃


Best,

Rachel


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!].


graphql.org

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]
}


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: d$itemId]) {
column_values(ids: d$startColumnId, $endColumnId]) {
value
}
}
}
`;
const variables = { startColumnId, endColumnId, itemId };

const response = await mondayClient.api(query, { variables });
console.log ('response timeline:', response);
if (response.data.itemst0].column_valuesl0].value !== null && response.data.itemst0].column_valuesl1].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: dString] 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.


Hello there,


Let’s please continue this in this topic 😁


Reply