Skip to content

Conversation

@olegkron
Copy link

@olegkron olegkron commented Apr 5, 2023

Added a function which allows to modify multiple items at once using graphQL's mutation query.
The function takes a list of dictionaries with methods and any additional parameters the method requires.

This already saved me hours when working with large sets of data, as the only way to work with multiple items with this library was to call the update/create functions one by one, whereas now you're able to perform multiple operations at once.

Hope you find it as much of a lifesaver too!

items_data = [
    {
        "method": "create_item",
        "board_id": 1437462152,
        "group_id": "new_group",
        "item_name": "New Item",
        "column_values": {"status": "done"},
        "create_labels_if_missing": True
    },
    {
        "method": "change_multiple_column_values",
        "board_id": 1435323152,
        "item_id": 1345543264,
        "column_values": {"status": "done"},
        "create_labels_if_missing": True
    }
]

response = monday.items.mutate_multiple_items(items_data)

@olegkron
Copy link
Author

Hi @chdastolfo, please let me know if there's time to review this pull request. Thanks!

Copy link
Collaborator

@chdastolfo chdastolfo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! This looks good, but could you please add test(s) for this as well? It would be good, for example, to make sure this query looks right for various lengths of if the item_data array (length, 1, >1).



def create_board_by_workspace_query(board_name: str, board_kind: BoardKind, workspace_id = None) -> str:
def create_board_by_workspace_query(board_name: str, board_kind: BoardKind, workspace_id=None) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

str(create_labels_if_missing).lower())


def mutate_multiple_items_query(items_data):
Copy link
Collaborator

@chdastolfo chdastolfo Apr 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer item_data, and data as it is more grammatically correct than items_data and item_data. I think the function name makes it clear that the function acts on multiple items.

@chdastolfo
Copy link
Collaborator

Also! Please add this method to the docs in docs/README.rst

@danielcherrington
Copy link

danielcherrington commented Jul 4, 2024

@chdastolfo Being able to group mutations/queries is a really useful feature. Are there any plans for this PR to make it into a release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants