Yes, you could query User data while fetching TeamMember information.

Consider this example:

schema.prisma

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model TeamMember {
  id      Int   @id @default(autoincrement())
  team_id Int
  User    User? @relation(fields: [userId], references: [id])
  userId  Int?
}

model User {
  id       Int          @id @default(autoincrement())
  name     String
  email    String
  password String
  team     TeamMember[]
}

index.ts

import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient({
  log: ['query'],
});

async function main() {
  await prisma.user.create({
    data: {
      email: 'test@test.com',
      name: 'test',
      password: 'test',
      team: {
        create: {
          team_id: 1,
        },
      },
    },
  });

  console.log('Created user');

  const teamWithUsers = await prisma.teamMember.findUnique({
    where: {
      id: 1,
    },
    include: {
      User: true,
    },
  });

  console.log('teamWithUsers', teamWithUsers);
}

main()
  .catch((e) => {
    throw e;
  })
  .finally(async () => {
    await prisma.$disconnect();
  });

Here's the response:

teamWithUsers {
  id: 1,
  team_id: 1,
  userId: 1,
  User: { id: 1, name: 'test', email: 'test@test.com', password: 'test' }
}

By default relation fields are not fetched, if you need to get the relation fields data in that case you would need to specify the include clause as demonstrated in the above example.

Answer from Nurul Sundarani on Stack Overflow
🌐
Prisma
prisma.io › home › relation queries › relation queries › relation queries › relation queries
Relation queries (Concepts) | Prisma Documentation
Prisma Client supports two load ... data with a single query to the database. query: Sends multiple queries to the database (one per table) and joins them on the application level....
🌐
GitHub
github.com › prisma › prisma › discussions › 12715
Performance: How to make prisma perform a single SQL query with joins instead of multiple queries · prisma/prisma · Discussion #12715
Which seems unlikely but I'd really like to hear the Prisma team say all is transactional, not just the special cases listed on the doco page I referenced above. Beta Was this translation helpful? Give feedback. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... In order for the nested case to be successful, the nested queries should be run as subqueries (or joins instead).
Author   prisma
Discussions

Making duel queries in prisma client
I'm currently wondering if its possible to get data from more than one table in a single query? We have a teamMember table, and a user table. We want to fetch information on each user in the teamMe... More on stackoverflow.com
🌐 stackoverflow.com
July 28, 2022
Multiple queries in prisma graphql resolver - Stack Overflow
Following this example here: https://github.com/prisma/prisma-examples/blob/latest/javascript/graphql-sdl-first/src/schema.js Let's say I have a mutation where I want to update multiple users by pa... More on stackoverflow.com
🌐 stackoverflow.com
September 26, 2022
Batch multiple Client queries into one Engine request (GraphQL Query)
Problem The Query engine supports a MultiQuery graphql query. This can be used to group unrelated queries against the database into one Graphql query. The Query Engine will then run each of these q... More on github.com
🌐 github.com
2
April 6, 2022
Why multiple queries for returning data + count?
I see answers such as #8103 and #3087 which both essentially recommend executing the two calls separately, in a transaction to return both the data + dataCount. This does work and thank you for she... More on github.com
🌐 github.com
2
11
August 19, 2021
🌐
Stack Overflow
stackoverflow.com › questions › 77878120 › how-to-run-multiple-queries-in-one-call-in-prisma-orm-with-postgresql
express - how to run multiple queries in one call in prisma orm with postgresql - Stack Overflow
Sign up to request clarification or add additional context in comments. ... Save this answer. ... Show activity on this post. Currently you cannot send multiple queries in single prisma call.
🌐
Stack Overflow
stackoverflow.com › questions › 73857879 › multiple-queries-in-prisma-graphql-resolver
Multiple queries in prisma graphql resolver - Stack Overflow
September 26, 2022 - I know the updateMany would probably be the most suitable option, but since different users would have different values, not sure how to pass that without calling multiple resolvers separately. Something like this: updateUsers: (_parent, args, context) => { return context.prisma.user.updateMany({ where: { id: { in: args.userIds }, }, data: { email: ???
🌐
Prisma
prisma.io › home › crud › crud › crud › crud
CRUD (Reference) | Prisma Documentation
Delete a user and all their posts with two separate queries in a transaction (all queries must succeed): const deletePosts = prisma.post.deleteMany({ where: { authorId: 7, }, }); const deleteUser = prisma.user.delete({ where: { id: 7, }, }); ...
🌐
GitHub
github.com › prisma › prisma › issues › 12688
Batch multiple Client queries into one Engine request (GraphQL Query) · Issue #12688 · prisma/prisma
April 6, 2022 - But when running those queries against the PDP this would be a nice improvement as it would mean that multiple queries are done using a single HTTP request. Given the following queries: let p1 = prisma.users.findMany({where: {age: 40}}); let p2 = prisma.blog.findMany({where: {title: "cats"}}); let p3 = prisma.product.findMany({where: {name: "crocs"}}); await Promise.allSettled([p1, p2, p3]); Internally the Prisma Client would convert those into a single Graphql statement like this: { batch: [ "{ findManyUser(where: {age: 40}) { id } }", "{ findManyBlog(where: {title: "cats"}) { id } }", "{ findManyProduct(where: {title: "crocs"}) { id } }", ], transaction: false } This code is then executed here in the query engine and a batch result would be returned that the user could use.
Author   prisma
Find elsewhere
🌐
Prisma
prisma.io › blog › prisma-orm-now-lets-you-choose-the-best-join-strategy-preview
Choosing the Best Join Strategy in Prisma ORM: join vs query
February 21, 2024 - On the application-level: Multiple queries are sent to the database. Each query only accesses a single table and the query results are then merged in-memory in the application layer.
🌐
Prisma
prisma.io › home › transactions and batch queries › transactions and batch queries › transactions and batch queries › transactions and batch queries
Transactions and batch queries (Reference) | Prisma Documentation
Prisma Client supports multiple ways of handling transactions, either directly through the API or by supporting your ability to introduce optimistic concurrency control and idempotency into your application.
🌐
GitHub
github.com › prisma › prisma › issues › 2868
`$executeRaw` could support multiple queries from a single string · Issue #2868 · prisma/prisma
June 26, 2020 - db.executeRaw could support running multiple queries instead of only one ... kind/featureA request for a new feature.A request for a new feature.topic: raw$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-cli$queryRaw(Unsafe) and $executeRaw(Unsafe): https://www.prisma.io/docs/concepts/components/prisma-clitopic: transaction
Author   prisma
🌐
Nico's Blog
nico.fyi › blog › prisma-join-relation
The new join relation in Prisma | Nico's Blog
March 5, 2024 - Recently, Prisma released a highly requested feature: support for database-level joins. Previously, Prisma sent multiple queries to retrieve related data, then combined the results at the application level.
🌐
Answer Overflow
answeroverflow.com › m › 1101515869818986618
Why prisma do 2 seperate Queries instead of 1 left join? - Theo's Typesafe Cult
April 28, 2023 - prisma:query SELECT "public"."Session"."id", "public"."Session"."userId", "public"."Session"."refreshToken", "public"."Session"."accessToken", "public"."Session"."expiresAt", "public"."Session"."ip", "public"."Session"."userAgent", "public"."Session"."createdAt", "public"."Session"."updatedAt" FROM "public"."Session" WHERE ("public"."Session"."refreshToken" = $1 AND 1=1) LIMIT $2 OFFSET $3 prisma:query SELECT "public"."User"."id", "public"."User"."name", "public"."User"."email", "public"."User"."password", "public"."User"."clubId", "public"."User"."createdAt", "public"."User"."updatedAt" FROM "public"."User" WHERE "public"."User"."id" IN ($1) OFFSET $2 I believe this should, to optimize performance, be send as a single query with a join.
🌐
Prisma Client Python
prisma-client-py.readthedocs.io › en › stable › reference › operations
Query Operations - Prisma Client Python - Read the Docs
In lieu of more extensive documentation, this page documents query operations on the prisma client such as creating, finding, updating and deleting records.
🌐
Stack Overflow
stackoverflow.com › questions › 70223111 › how-to-query-with-prisma-multiple-inner-joins
prisma2 - How to query with Prisma multiple inner joins? - Stack Overflow
December 4, 2021 - const products = await prisma.products.findMany({ where: { is_enable: true, is_deleted: false, }, include: { items: { where: { is_deleted: false }, include: { parts: { where: { is_deleted: false, }, include: { subvehicles: { include: { vehicles: { include: { manufacturers: true } } } } } } } } }, skip: replacements.offset, take: replacements.limit, });
🌐
Answer Overflow
answeroverflow.com › m › 1118542076712321136
Prisma query multiple tables - Theo's Typesafe Cult
June 14, 2023 - How would I go about doing this? ... Prisma Client provides convenient queries for working with relations, such as a fluent API, nested writes (transactions), nested reads and relation filters.