Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/monday_sdk/modules/updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
class UpdateModule:
def __init__(self, graphql_client: MondayGraphQL):
self.client = graphql_client
def create_update(self, item_id, update_value) -> MondayApiResponse:
query = create_update_query(item_id, update_value)
def create_update(self, item_id, update_value, mentions_list: Optional[List[UpdateMentions]]) -> MondayApiResponse:
mentions_str = self._convert_mentions_to_graphql(mentions_list)
query = create_update_query(item_id, update_value, mentions_str)
return self.client.execute(query)

def delete_update(self, item_id) -> MondayApiResponse:
Expand Down Expand Up @@ -106,4 +107,25 @@ def fetch_board_updates_incremental(
If using an older API version, use fetch_board_updates() instead which
provides client-side date filtering.
"""
return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date)
return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date)

def _convert_mentions_to_graphql(self, mentions_list: Optional[List[UpdateMentions]]):
"""Convert a Python list of mention dictionaries to GraphQL format string.

Args:
mentions_list: Optional[List[UpdateMentions]]
Example: [{"id": 60875578, "type": "User"}]

Returns:
GraphQL formatted string: "[{id: 60875578, type: User}]"
"""
if not mentions_list or not isinstance(mentions_list, list):
return "[]"

mention_strings = []
for mention in mentions_list:
# Build the mention string with unquoted keys and enum type
mention_str = f"{{id: {mention['id']}, type: {mention['type']}}}"
mention_strings.append(mention_str)

return f"[{', '.join(mention_strings)}]"
6 changes: 4 additions & 2 deletions src/monday_sdk/query_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,18 +473,20 @@ def update_multiple_column_values_query(board_id, item_id, column_values, create


# UPDATE RESOURCE QUERIES
def create_update_query(item_id, update_value):
def create_update_query(item_id, update_value, mentions: str):
query = """mutation
{
create_update(
item_id: %s,
body: %s
body: %s,
mentions_list: %s
) {
id
}
}""" % (
item_id,
json.dumps(update_value, ensure_ascii=False),
mentions
)

return query
Expand Down
1 change: 1 addition & 0 deletions src/monday_sdk/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
Document,
)
from .monday_enums import BoardKind, BoardState, BoardsOrderBy, Operator
from .utils import UpdateMentions
6 changes: 6 additions & 0 deletions src/monday_sdk/types/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from typing import TypedDict

class UpdateMentions(TypedDict):
"""TypedDict for updating mentions in a Monday.com column."""
id: int
type: str
Loading