I have defined a mutation which lets users duplicate their products, one product at a time:
mutation DuplicateProduct($productID: ID!) {
duplicateProduct(productID: $productID) {
id
}
}
Now I have to implement a feature, which would allow users to duplicate multiple products at once.
One obvious solution is to redesign the schema to accept multiple product IDs. I'd like to avoid that work if possible.
Another option is to simply post the same mutation multiple times in a row, but it appears that with the way CodeGen generates the mutation services, I'd have to send multiple separate HTTP requests.
My question is this: is it possible to batch a dynamic number of mutations in a single request using the CodeGen-generated services? It seems like batching would be easy if I didn't use CodeGen, since I could just create the mutation definition dynamically on the fly. However, CodeGen seems to enforce rather static operation definitions.
Is there a nice way to achieve what I am looking for? I might be going the wrong way about this too, so if the most graphql-y solution actually requires a schema redesign, I'd be happy if someone pointed this out to me.types