Multiple Queries in the server


#1

My schema

type User {
  id: ID! @unique
  email: String @unique
  password: String!
  verified: Boolean! @default(value: "false")

  name: Name!
  business: Business @default(value: "null")
}

type Business {
  id: ID! @unique
  owner: User!
  name: String!

My code on the server

    const userPromise = context.prisma.user({ email });
    const businessPromise = context.prisma.user({ email }).business();

    const [user, business] = await Promise.all([userPromise, businessPromise]);

    const token = jwt.sign({ userId: user.id, businessId: business.id }, 'TEMP_SECRET');

Is this the right way to do it? Is there a query where we can fetch both in one instead of making 2 separate queries?