Skip to content

Commit a373be0

Browse files
committed
support updates mentions
1 parent 050a745 commit a373be0

File tree

4 files changed

+36
-5
lines changed

4 files changed

+36
-5
lines changed

src/monday_sdk/modules/updates.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88
class UpdateModule:
99
def __init__(self, graphql_client: MondayGraphQL):
1010
self.client = graphql_client
11-
def create_update(self, item_id, update_value) -> MondayApiResponse:
12-
query = create_update_query(item_id, update_value)
11+
def create_update(self, item_id, update_value, mentions_list: Optional[List[UpdateMentions]]) -> MondayApiResponse:
12+
mentions_str = self._convert_mentions_to_graphql(mentions_list)
13+
query = create_update_query(item_id, update_value, mentions_str)
1314
return self.client.execute(query)
1415

1516
def delete_update(self, item_id) -> MondayApiResponse:
@@ -106,4 +107,25 @@ def fetch_board_updates_incremental(
106107
If using an older API version, use fetch_board_updates() instead which
107108
provides client-side date filtering.
108109
"""
109-
return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date)
110+
return self.fetch_board_updates_page(board_id, limit, page, from_date, to_date)
111+
112+
def _convert_mentions_to_graphql(self, mentions_list: Optional[List[UpdateMentions]]):
113+
"""Convert a Python list of mention dictionaries to GraphQL format string.
114+
115+
Args:
116+
mentions_list: Optional[List[UpdateMentions]]
117+
Example: [{"id": 60875578, "type": "User"}]
118+
119+
Returns:
120+
GraphQL formatted string: "[{id: 60875578, type: User}]"
121+
"""
122+
if not mentions_list or not isinstance(mentions_list, list):
123+
return "[]"
124+
125+
mention_strings = []
126+
for mention in mentions_list:
127+
# Build the mention string with unquoted keys and enum type
128+
mention_str = f"{{id: {mention['id']}, type: {mention['type']}}}"
129+
mention_strings.append(mention_str)
130+
131+
return f"[{', '.join(mention_strings)}]"

src/monday_sdk/query_templates.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,18 +473,20 @@ def update_multiple_column_values_query(board_id, item_id, column_values, create
473473

474474

475475
# UPDATE RESOURCE QUERIES
476-
def create_update_query(item_id, update_value):
476+
def create_update_query(item_id, update_value, mentions: str):
477477
query = """mutation
478478
{
479479
create_update(
480480
item_id: %s,
481-
body: %s
481+
body: %s,
482+
mentions_list: %s
482483
) {
483484
id
484485
}
485486
}""" % (
486487
item_id,
487488
json.dumps(update_value, ensure_ascii=False),
489+
mentions
488490
)
489491

490492
return query

src/monday_sdk/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
Document,
1717
)
1818
from .monday_enums import BoardKind, BoardState, BoardsOrderBy, Operator
19+
from .utils import UpdateMentions

src/monday_sdk/types/utils.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import TypedDict
2+
3+
class UpdateMentions(TypedDict):
4+
"""TypedDict for updating mentions in a Monday.com column."""
5+
id: int
6+
type: str

0 commit comments

Comments
 (0)