我想在同一个查询中运行多个突变。
在下面的示例中,我创建了一个订单,然后创建了一个产品记录,涉及先前创建的。
我必须有2个突变。
首先,我插入一个订单。在输出中,我检索了 idorder。
然后,我插入一个产品。这个产品
mutation {
createOrder(input: {
order: {
ordername: "My order"
}
}) {
order {
idorder
ordername
}
},
createProduct(input: {
product: {
quantity: 3
idrefproduct: 25 # link to refProduct
idorder: XXXX # how can i retrieve idorder from output of createOrder above ?
}
}) {
product {
idproduct
}
}
}
SQL结构的真实示例:
user(iduser, othersFields);
scenarios(idscenario, iduser, name, otherFields);
cultA(idcultA, idscenario, ...); // this table need of idscenario field
cultB(idcultB, idscenario, ...); // this table need of idscenario field
cultC(idcultC, idscenario, ...); // this table need of idscenario field
如何从上面的 createOrder 输出中检索 idorder?
有可能的 ?
如果我忘记了一些信息,请不要犹豫。
提前致谢。
编辑:
- 使用 PostGraphile,插件“postgraphile-plugin-nested-mutations”或“自定义突变”(带有 PL PGSQL 功能)
- 在没有 PostGraphile 的情况下,作为 @xadm 示例的解析器允许这种特定的嵌套突变。