Multiple Queries in the server


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:, businessId: }, '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?


This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.