[英]How do you correctly seed a prisma DB with a custom file that has multiple mutations?
I am trying to seed my Prisma DB using a custom file I created which I then reference in prisma.yml
.我正在尝试使用我创建的自定义文件为 Prisma DB 播种,然后我在
prisma.yml
引用该prisma.yml
。 In this file, I have a few mutations - nothing too crazy.在这个文件中,我有一些变化——没什么太疯狂的。 Everything seems to be working fine when I have ONE mutation.
当我有一个突变时,一切似乎都正常。 However, if I add more than one I end up getting this error:
Must provide operation name if query contains multiple operations: {"response":{"data":null,"errors":[{"message":"Must provide operation name if query contains multiple operations"}],"status":200}
.但是,如果我添加多个,我最终会收到此错误:
Must provide operation name if query contains multiple operations: {"response":{"data":null,"errors":[{"message":"Must provide operation name if query contains multiple operations"}],"status":200}
。 I assumed this operation name
is the createSomething
in mutation createSomething {...}
, but I guess that is not the case.我以为这
operation name
是createSomething
在mutation createSomething {...}
但我想这是不是这样的。 Is there anything I am missing here?有什么我在这里想念的吗?
Having multiple mutations in the playground also seems to be working fine.在操场上有多个突变似乎也工作正常。 Looks like the problem is when the seeder tries to run them all one after the other.
看起来问题出在播种机试图一个接一个地运行它们时。
prisma.yml棱镜.yml
seed:
import: seeds/something.graphql
something.graphql东西.graphql
mutation createSomething {
createSomething(data: { key1: "val1", key2: "val2" }) {
key1
val1
}
}
Figured out the answer.想通了答案。
Turns out you need to nest them all under the mutation
keyword and then alias them to allow for multiple mutations.事实证明,您需要将它们全部嵌套在
mutation
关键字下,然后为它们取别名以允许多个突变。
mutation {
something1: createSomething(data: {
key1: "val1"
})
something2: createSomething(data: {
key2: "val2"
})
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.