Can you execute “add_file_to_column” and “create_item” in the same mutation? If so does anyone have an example mutation? The goal is to upload a file to a column within the newly created item.
Hi @gmrstudios
What I do (in Wordpress PHP) is to create the item and use the returned id to do the file upload in a column. Something like this?
Hey @gmrstudios.
As said by @basdebruin, I don’t see the problem in using two queries.
The first query will return the ID of the item just created, that you will use then to upload the file.
Hey @basdebruin and @rob
Thank you so much for your input here! I really appreciate your help, you guys are the best.
@gmrstudios is the solution provided above working well for you? Let us know
-Alex
Thank you @rob @basdebruin. What is the best way to pull that ID after its inserted? Just reference it after the first query is returned?
Don’t know if I fully understand your question. The create_item mutation returns anything you want from the item. In the example given I only asked for the id. You can use that item id in follow up mutations to add files to a file column.
It’s directly returned by the creation query.
It’s not like MySQL where you need to use last_inserted_id
.
Something like this?
$obj = json_decode($response);
$item_id = $obj->data->create_item->id;
Yes, when you create a new item.
mutation {
create_item(board_id: BOARD_ID, group_id: "GROUP_ID", item_name: "New item") {
id
}
}
You’ll get ID of the item just created.
data: {
create_item: {
id: ITEM_ID
}
}