title: Prisma2: use user id in related table in create function
body: <p>I am trying to create a user that is the child of another user. I am managing this relationship by having a User table where all users, parents and children, are stored. There is a seperate table that just has the id of the child and the id of the parent.  </p>
  
  <p>My problem is that when I create a child account I want to create an entry in the <code>Relationship</code> table using the user id that would be created. I am not sure at all how I should go about this.  </p>
  
  <p>// schema.sql</p>
  
  <pre><code>CREATE TABLE "public"."Relationship" (
      id SERIAL PRIMARY KEY NOT NULL,
      parent_id INT NOT NULL,
      FOREIGN KEY (parent_id) REFERENCES "User" (id),
      child_id INT NOT NULL,
      FOREIGN KEY (child_id) REFERENCES "User" (id)
  )
  
  CREATE TABLE "public"."User" (
      id SERIAL PRIMARY KEY NOT NULL,
      name VARCHAR(128) NOT NULL,
      email VARCHAR(128) UNIQUE,
      password VARCHAR(128) NOT NULL,
      isChild BOOLEAN NOT NULL DEFAULT false
      created_at TIMESTAMP NOT NULL DEFAULT NOW();
  );
  </code></pre>
  
  <p>// CreateChild User mutation</p>
  
  <pre><code>export const createChildAccount = mutationField('createChildAccount', {
    type: 'User',
    args: {
      name: stringArg({ required: true }),
      password: stringArg({ required: true }),
    },
    resolve: async (_parent, { name, password }, ctx) =&gt; {
      const userId = getUserId(ctx);
      if (!userId) {
        // TODO -think I might need to throw an error here
        return;
      }
      const user = await ctx.prisma.user.create({
        data: {
          name,
          password,
          ischild: true,
          child: {
            create: { child_id: ???????? },
          },
          parent: {
            connect: {id: userId}
          }
        },
      });
      return user;
    },
  });
  </code></pre>
  
  <p>Should I actually be creating a <code>Relationship</code> and then using that to connect the parent and create the child?</p>