hey! I’m trying to populate my database with dummy...
# orm-help
c
hey! I’m trying to populate my database with dummy data and I’m using the
seed.graphql
file to do so. I’ve defined 3 mutations to add dummy users and named them differently. When executing I’m getting the following error:
Copy code
ERROR: Must provide operation name if query contains multiple operations

{
  "data": null,
  "errors": [
    {
      "message": "Must provide operation name if query contains multiple operations"
    }
  ],
  "status": 200
}
The used
seed.graphql
works if I copy it into GraphqL Playground. Can the seed file only contain one mutation? Here’s the `seed.graphql`:
Copy code
mutation addUserA {
  createUser(data: {
    email: "<mailto:usera@example.de|usera@example.de>"
    password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm"
    firstname: "User"
    lastname: "A"
  }) {
    id
  }
}

mutation addUserB {
  createUser(data: {
    email: "<mailto:userb@example.de|userb@example.de>"
    password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm"
    firstname: "User"
    lastname: "B"
  }) {
    id
  }
}

mutation addUserC {
  createUser(data: {
    email: "<mailto:userc@example.de|userc@example.de>"
    password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm"
    firstname: "User"
    lastname: "C"
  }) {
    id
  }
}
n
Can the seed file only contain one mutation?
yes.
c
alright, I’ve missed that issue. What option would you choose for this use case? Generate data and export them to load the
.zip
?
n
I would probably use the
run
script option
but your suggestion is also great
c
alright. Write a litte script that just fires the mutations one after another?
n
yup
s
Does this not work?
Copy code
mutation  {
  addUserA: createUser(data: {
    email: "<mailto:usera@example.de|usera@example.de>"
    password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm"
    firstname: "User"
    lastname: "A"
  }) {
    id
  }

  addUserB: createUser(data: {
    email: "<mailto:userb@example.de|userb@example.de>"
    password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm"
    firstname: "User"
    lastname: "B"
  }) {
    id
  }

  addUserC: createUser(data: {
    email: "<mailto:userc@example.de|userc@example.de>"
    password: "$2a$10$hACwQ5/HQI6FhbIISOUVeusy3sKyUDhSq36fF5d/54aAdiygJPFzm"
    firstname: "User"
    lastname: "C"
  }) {
    id
  }
}
ie. a single mutation with named transactions.
n
it does work, good point @stephen!
c
works, thanks @stephen! 🙂
👍 1