Bulk update of Items through API?

I just managed to do bulk update by mutating the query before sending it

  static async bulkCreateSubItems(token, itemId, values) {
    try {
      const mondayClient = initMondayClient({ token });

      const queryStrings = values
        .map(
          (value, index) =>
            `si${index}: create_subitem(parent_item_id: $itemId, item_name: "${value}") { id }`
        )
        .join(" ");

      const query = `mutation bulk_create_sub_items($itemId: Int!) { ${queryStrings} }`;

      const variables = { itemId };

      const response = await mondayClient.api(query, { variables });
      return response;
    } catch (err) {
      console.log(err);
    }
  }
}
1 Like