I am creating a entity called PhoneBook that has a...
# orm-help
p
I am creating a entity called PhoneBook that has a
owner: User!
relationship. When I create the user I automatically create a PhoneBook for it. I then want to add a entry into the PhoneBook, but I need to link the entry. When calling
ctx.db.mutation.creatEntry()
I need to have the phoneBookId to connect it. The only thing I have is the JWT, which gives me the UserId, but what do I do with it? I can't call
ctx.db.query.user
as it doesn't return the phonebook entity with it. When I try to add a 2nd param and call
ctx.db.query.user({where: {id}, '{ phonebook { id }}'})
it throws an error.
m
@Pieter can all the steps be done in one go? If so, try this (something similar)
Copy code
ctx.db.mutation.createUser({
  data: {
    phoneBook: {
      create: {
        name: "Cool pb",
        entries: {
          create: [{
            name: "entry"
          }]
        }
      }
    }
  }
})
besides that, what’s the error that you are receiving?
p
The phonebook is already created
so it's not a matter of doing it at once
I need to add entries to a phonebook one at a time as the user does it on the UI
if I try and get a phonebook with a given userId I get this error:
Copy code
"errors": [
    {
      "message": "You provided an invalid argument for the where selector on PhoneBook.",
ctx.db.query.phoneBook({where: {owner: {id}}})
nevermind, I came right. Not sure what I changed now. I literally just went back to what I had earlier and it worked. Must be some cached issue
Thanks for the help