Hey @dannysmc95 👋 !

Since Prisma queries do not include relations by default (you have to use the include option), the generated types do not include them either. You can create the type you are looking for using one of our built-in utility types, though.

import { Prisma } from '@prisma/client'
type FactionWithOwner = Prisma.FactionGetPayload<{
  include: { owner: true }
}>

Here we use the FactionGetPayload type and pass in some query options as the generic parameter to get the desired type.

Let me know if you have any questions about this!

🌐
Prisma
prisma.io › home › operating against partial structures of your model types › operating against partial structures of your model types › operating against partial structures of your model types › operating against partial structures of your model types
Operating against partial structures of your model types | Prisma Documentation
A cleaner solution to this is to use the UserGetPayload type that is generated and exposed by Prisma Client under the Prisma namespace in combination with TypeScript's satisfies operator. The following example uses the satisfies operator to create two type-safe objects and then uses the Prisma.UserGetPayload utility function to create a type that can be used to return all users and their posts. import { Prisma } from "@prisma/client"; // 1: Define a type that includes the relation to `Post` const userWithPosts = { include: { posts: true } } satisfies Prisma.UserDefaultArgs; // 2: Define a type that only contains a subset of the scalar fields const userPersonalData = { select: { email: true, name: true } } satisfies Prisma.UserDefaultArgs; // 3: This type will include a user and all their posts type UserWithPosts = Prisma.UserGetPayload<typeof userWithPosts>;
Discussions

get full type on prisma client - Stack Overflow
You can use the Prisma Validator API along with some typescript features to generate types for your query. ... import { Prisma } from '@prisma/client' // 1. Define a User type that includes the "cars" relation. More on stackoverflow.com
🌐 stackoverflow.com
How to get Prisma client to generate relationship types
I am trying to create a one-to-many relationship between a user and posts. I can create the database schema and can write / query all ok but it appears the prisma client that is being generated doe... More on stackoverflow.com
🌐 stackoverflow.com
Composing relation types
type ProjectWithTasks = Prisma.ProjectGetPayload<{ ... This approach allows you to create specific types for different combinations of relations without manually combining them. 2. Using TypeScript's utility types: As suggested in a GitHub discussion about partial types, you can use TypeScript's ... More on answeroverflow.com
🌐 answeroverflow.com
March 7, 2025
Declare type for relational fields
What's the idiomatic way of declaring the type of an relational field from the autogenerated TS types? Let's say I have a simple Schema of User and Post: model User { id String @id @default(uuid())... More on github.com
🌐 github.com
2
3
February 25, 2022
🌐
Codú
codu.co › home › feed › niall maher › how to get specific types from the prisma client with relations
How to Get Specific Types from the Prisma Client with Relations | by Niall Maher | Codú
May 1, 2024 - import { PrismaClient, Prisma } from '@prisma/client'; const prisma = new PrismaClient(); // Given this query async function fetchUserWithCars(id: number): Promise<UserWithCars> { return prisma.user.findUnique({ where: { id }, include: { cars: true, }, }); } // How we can generate just the types for the above query type UserWithCars = Prisma.UserGetPayload<{ include: { cars: true; } }>
🌐
Prisma
prisma.io › home › type safety overview › type safety overview › type safety overview
Type safety | Prisma Documentation
You would usually use this in conjunction with Args. As with Args, Result helps you to re-use existing types to extend or modify them. Payload<Type, Operation>: Retrieves the entire structure of the result, as scalars and relations objects for a given model and operation.
🌐
Medium
medium.com › @jeevankc17 › understanding-typescript-types-with-prisma-e0e41a7d98f3
Understanding TypeScript Types with Prisma | by Jeevan KC | Medium
December 17, 2024 - Prisma handles relations for you dynamically. This step ensures your types reflect your database structure and relationships. Once you have the base types and payload types, you refine them based on the requirements of your application.
🌐
Prisma
prisma.io › typescript
TypeScript ORM with zero-cost type-safety for your database | Prisma
Prisma is an ORM for Node.js and TypeScript that gives you the benefits of type-safety at zero cost by auto-generating types from your database schema. ... Queries with Prisma Client always have their return type inferred making it easy to reason about the returned data – even when you fetch relations...
Top answer
1 of 10
103

An alternate method (my preferrence) to get the "full" type, or the model with all of its possible relations, is to use the GetPayload version of your model type. The type is a generic that can receive the same object you pass to your query.

import { PrismaClient, Prisma } from "@prisma/client";

const prisma = new PrismaClient();

type UserWithCars = Prisma.UserGetPayload<{
  include: {
    cars: true;
  }
}>

const usersWithCars = await prisma.user.findMany({
  include: {
    cars: true,
  }
});

As your query grows more complex, you may want to abstract it and ensure that it is strongly typed.

import { Prisma, PrismaClient } from "@prisma/client";

const prisma = new PrismaClient();

const userInclude = Prisma.validator<Prisma.UserInclude>()({
  cars: true,
});

type UserWithCars = Prisma.UserGetPayload<{
  include: typeof userInclude;
}>;

const usersWithCars = await prisma.user.findMany({
  include: userInclude,
});

2 of 10
20

You can use the Prisma Validator API along with some typescript features to generate types for your query.

For the findMany example you mentioned

import { Prisma } from '@prisma/client'

// 1. Define a User type that includes the "cars" relation. 
const userWithCars = Prisma.validator<Prisma.UserArgs>()({
    include: { cars: true },
})

// 2: This type will include many users and all their cars
type UserWithCars = Prisma.UserGetPayload<typeof userWithCars>[]

If you simply want to automatically infer the return type of a prisma query wrapped in a function, you can use PromiseReturnType.

For example:

import { Prisma } from '@prisma/client'

async function getUsersWithCars() {
  const users = await prisma.user.findMany({ include: { cars: true } });
  return users;
}

type UsersWithCars = Prisma.PromiseReturnType<typeof getUsersWithCars>

You can read more about this in the Operating against partial structures of your model types concept guide in the Prisma docs.

Find elsewhere
🌐
Answer Overflow
answeroverflow.com › m › 1347585163198070908
Composing relation types - Prisma
March 7, 2025 - type ProjectWithTasks = Prisma.ProjectGetPayload<{ ... This approach allows you to create specific types for different combinations of relations without manually combining them. 2. Using TypeScript's utility types: As suggested in a GitHub discussion about partial types, you can use TypeScript's utility types like Pick or intersection types to create combinations:
🌐
YouTube
youtube.com › coding in flow
How to Generate Types for Prisma Relation Queries - YouTube
How to use the GetPayload helper to generate TypeScript types for the include filter in your relation queries in Prisma.⭐ Get my full-stack Next.js with Expr...
Published   July 14, 2023
🌐
Digital Thrive
digitalthriveai.com › en-ie › resources › docs › web-development › prisma › prisma-relations
Prisma Relations - Type-Safe ORM for TypeScript Developers | Digital Thrive Ireland
March 15, 2026 - Required relations (without ?) enforce foreign key constraints, while optional relations allow NULL values. One-to-One: Use when records have a one-to-one correspondence, like user profiles · One-to-Many: Most common pattern, like users authoring posts in a content management system · Many-to-Many: Choose implicit for simple cases, explicit when needing join metadata · Type Safety: Prisma generates complete TypeScript types for all queries
🌐
Stack Overflow
stackoverflow.com › questions › 78807331 › how-to-let-return-type-depend-on-relations-included-in-prisma-object
typescript - How to let return type depend on relations included in Prisma object - Stack Overflow
import { Prisma } from "@prisma/client"; const getVersion = < Relations extends Prisma.AppVersionInclude, App extends Prisma.AppGetPayload<{ include: { versions: { include: Relations } }; }>, >( app: App, ): Prisma.AppVersionGetPayload<{ include: Relations }> => { return app.versions[0]!; }; const withRelations = await prisma.app.findUnique({ where: { id: "foo" }, include: { versions: { include: { pages: true, variables: true, actions: true, }, }, }, }); const withoutRelations = await prisma.app.findUnique({ where: { id: "foo" }, include: { versions: true, }, }); const versionWithRelations = g
🌐
Stack Overflow
stackoverflow.com › questions › 79322241 › how-to-get-prisma-model-type-including-relations
reactjs - How to get Prisma model type including relations? - Stack Overflow
But how do I get a typescript type so that I can pass this object to subcomponents of my react component? This only give me the Event type without the nested Owner property/relation. Copyimport { Event, Prisma } from "@prisma/client"; type EventDetailsProps = { event: Event; }; And this is not working too: Copytype EventDetailsProps = { event: Prisma.EventInclude; }; reactjs ·
🌐
Stack Overflow
stackoverflow.com › questions › 78823201 › dynamically-including-prismaorm-relations-with-type-safety
node.js - Dynamically including PrismaORM relations with type safety - Stack Overflow
Copyasync findById(id: string, relations: string[] = []) { if (relations.length === 0) { return prisma.contract.findUnique({ where: { id } }); } const includedRelations = relations.reduce((acc: Record<string, boolean>, curr: string) => { acc[curr] = true; return acc; }, {}); return prisma.contract.findUnique({ where: { id }, include: includedRelations }); }
🌐
Stack Overflow
stackoverflow.com › questions › 76377529 › typed-relation-query-using-prisma
typescript - Typed relation query using Prisma - Stack Overflow
Prisma automatically calculates the output TypeScript type based on what you pass into select, and the type that it emits will include everything (including nested properties, or models/tables that you have joined.)
🌐
GitHub
github.com › prisma › prisma › issues › 12022
No relations in typescript models · Issue #12022 · prisma/prisma
February 24, 2022 - Bug description In my model i have relation but, if you run npx prisma generate, no relations in type models. Generated models; /** * Model Customer * */ export type Customer = { id: string email: string password: string createdAt: Date ...
Author   prisma
🌐
Prisma
prisma.io › home › models › models › models › models
Models | Prisma Documentation
Fields without ? are required: Relational databases: Represented via NOT NULL constraints · Prisma Client: TypeScript types enforce these fields at compile time · When you introspect a relational database, unsupported data types are added as Unsupported: location Unsupported("POLYGON")? Fields of type Unsupported don't appear in the generated Prisma Client API, but you can still use raw database access to query them.