is there a way to connect two required fields in a...
# orm-help
t
is there a way to connect two required fields in a nested mutation, for example,
Role
requires a list of
[User!]!
and a single `Customer`… When I signup a user I want to create the new
Customer
, it’s first
User
and an admin
Role
for that
Customer
and
User
- how would I do this?
Copy code
const user = await ctx.db.createUser({
      firstname: firstname || undefined,
      lastname: lastname || undefined,
      email,
      password: hashedPassword,
      emailConfirmToken,
      emailConfirmed: false,
      inviteAccepted: true,
      customer: {
        create: {
          name: customerName
        }
      },
      role: {
        create: {
          name: "Admin",
          permissions: {
            connect: {
              allow: "SUDO"
            }
          }
        }
      }
    });
this creates the role on the user, but I also want the
Role
to be associated to the
Customer
created above it…? Do I have to create the
Role
in a separate request and then just connect it in the
customer
and
role
fields?
h
Create automatically connect the field too, you should be good here
t
yes - but it is
creating
and
connecting
the
Role
to the
User
but I also want this role connected to the
Company
that is also created and connected to this user
h
You can easily query users company if it is connected to the user