I am trying to seed my Prisma DB using a custom file I created which I then reference in 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}
. I assumed this operation name
is the createSomething
in mutation createSomething {...}
, but I guess that is not the case. 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
seed:
import: seeds/something.graphql
something.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 {
something1: createSomething(data: {
key1: "val1"
})
something2: createSomething(data: {
key2: "val2"
})
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.