cms
cms copied to clipboard
Cannot create entries in multiple sites with graphql
Description
Its not possible to create entries in multiple sites through the graphql api. Even though the docs say:
Determines which site(s) the elements should be saved to. Defaults to the primary site.
The api doesn't accept an array with id's.
Steps to reproduce
- Create mutation
mutation {
save_products_flavors_Entry(
title: "Example"
siteId: [1, 2]
) { id }
}
Additional info
- Craft version: 3.7.19
- PHP version: 7.4
- Database driver & version: Mysql:8
Tried a different way:
mutation Mutation1 {
save_edition_edition_Entry(title: "Test multisite create 2", description:"lasd", siteId: 2) {
id
}
}
mutation Mutation2 {
save_edition_edition_Entry(id: 3340, siteId: 3) {
id
}
}
Id in the second mutation is the one from the 1st, but the second mutation throws an error:
{
"errors": [
{
"message": "No such entry exists",
"extensions": {
"category": "graphql"
}
}
],
"data": {
"save_edition_edition_Entry": null
}
}
I just fixed the description for the siteId argument - it's a mistake and you can't save an entry to more than two sites at the same time.
Even more, Craft will propagate the entry to other sites for you - you shouldn't save them to other sites yourself.