The generated types do not include relations because queries don't return relations by default. To include the related models in your type, use the provided Prisma utility types like so:

import { Prisma } from '@prisma/client'

type UserWithPosts = Prisma.UserGetPayload<{
  include: { posts: true }
}>
Answer from Austin Crim on Stack Overflow
🌐
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>;
🌐
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.
Discussions

typescript - How to add type definitions for includes in a Prisma model? - Stack Overflow
The generated types do not include relations because queries don't return relations by default. To include the related models in your type, use the provided Prisma utility types like so: More on stackoverflow.com
🌐 stackoverflow.com
how to convert prisma schema to typescript types ?
If you run "prisma generate", you would generate all the ts interfaces based on the prisma schema. You can import those interfaces from "@prisma/client". Example: Prisma Schema: https://ibb.co/P5S53Pj Types generated automatically from the prima Schema: https://ibb.co/QrzbmX8 More on reddit.com
🌐 r/node
5
5
July 6, 2023
get full type on prisma client - Stack Overflow
When i generate my prisma client with prisma generate, i got an index.d.ts with all types from my database. But the probleme is that all type are "single" and there is no relations. When i More on stackoverflow.com
🌐 stackoverflow.com
Missing TypeScript generation for include syntax?
Hello, i use the following Version: "@prisma/client": "^3.8.1", i love the TypeScript generator from Prisma but i think something is missing for includes. This is my Prisma Mode... More on github.com
🌐 github.com
3
February 1, 2022
🌐
Prisma
prisma.io › home › type safety overview › type safety overview › type safety overview
Type safety | Prisma Documentation
In the above example myAge was initialized with a number so TypeScript guesses that it should be typed as a number. Going back to the UserSelect type, if you were to use dot notation on the created object userEmail, you would have access to all of the fields on the User model that can be interacted with using a select statement. model User { id Int @id @default(autoincrement()) email String @unique name String? posts Post[] profile Profile? } import { Prisma } from "../path/to/generated/prisma/client"; const userEmail: Prisma.UserSelect = { email: true, }; // properties available on the typed object userEmail.id; userEmail.email; userEmail.name; userEmail.posts; userEmail.profile;
🌐
Nico's Blog
nico.fyi › blog › prisma-include-query-with-satisfies-typescript
Reuse include in Prisma Query with TypeScript satisfies | Nico's Blog
January 31, 2024 - const relationToInclude = { participantGroup: { include: { course: true, }, }, } const doSomethingFirst = async () => { let participant = await prismaClient.participant.findFirst({ where: { id: 'some-uuid', }, include: relationToInclude, }) // do some other operations participant = await prismaClient.participant.update({ where: { id: 'some-uuid', }, data: { // update participant's data }, include: relationToInclude, }) await doSomethingWithParticipant(participant) } Great, now I no longer have repeating code. Additionally, TypeScript reminds me if I make a typo:
Find elsewhere
🌐
Prisma
prisma.io
Prisma | Agent Infrastructure for TypeScript
Prisma gives TypeScript and Node.js teams Prisma ORM, Prisma Postgres, and Prisma Compute: a type-safe ORM, managed Postgres, and Compute for deploying TypeScript apps, from schema to deployed app.
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.

🌐
Prisma
prisma.io › home › models › models › models › models
Models | Prisma Documentation
The data model definition part ... used with TypeScript, Prisma Client provides generated type definitions for your models and any variations of them to make database access entirely type safe....
🌐
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; } }>
🌐
WorkOS
workos.com › blog › prisma-orm-for-typescript
Prisma ORM for TypeScript - A technical primer — WorkOS
April 10, 2025 - Zero-cost type-safety: It automatically generates TypeScript types based on your schema, helping catch potential query errors at compile-time. Intuitive data modeling: You define your data model via the prisma.schema file using Prisma’s modeling ...
🌐
Webdevtutor
webdevtutor.net › blog › typescript-prisma-include
Using TypeScript with Prisma Include: A Comprehensive Guide
We'll walk through the process of creating models, specifying relationships between them, and generating Prisma client code with TypeScript typings. The include feature in Prisma allows you to fetch related data in a single query, reducing the number of database calls and improving performance.
🌐
GitHub
github.com › prisma › prisma › issues › 11537
Missing TypeScript generation for include syntax? · Issue #11537 · prisma/prisma
February 1, 2022 - after npx prisma generate i found the following TypeScript definition: There is no type definition for the _count. With ANY type the Code is running, but this can't be the solution. export type Station = { id: number name: string | null } The Result is a TypeScript Error for the _count.
Author   prisma
🌐
Stack Overflow
stackoverflow.com › questions › 77108237 › prisma-include-results-select-related-compatible-with-typescript
Prisma include results (select related) compatible with typescript? - Stack Overflow
Is there a way to generate prisma types with expanded definitions for possible foreign key relations, so that Typescript will allow this access? ... Save this answer. ... Show activity on this post. Ah, found the prisma supported answer in this doc: https://www.prisma.io/docs/concepts/components/prisma-client/advanced-type-safety/operating-against-partial-structures-of-model-types#problem-using-variations-of-the-generated-model-type ... import { Prisma } from '@prisma/client' const albumWithIncludes = Prisma.validator<Prisma.albumDefaultArgs>()({ include: { artist: true }, }) export type AlbumWithIncludes = Prisma.albumGetPayload<typeof albumWithIncludes>
🌐
xjavascript
xjavascript.com › blog › prisma-typescript
Prisma with TypeScript: A Comprehensive Guide — xjavascript.com
In the modern web development landscape, working with databases efficiently and safely is crucial. Prisma, combined with TypeScript, offers a powerful solution to interact with databases in a type-safe and developer-friendly way.
🌐
SabinTheDev
sabinadams.hashnode.dev › starting-a-prisma-typescript-project
Starting a Prisma + TypeScript Project - Sabin Adams
December 21, 2021 - In this tutorial we will set up Prisma with TypeScript and learn a bit about what Prisma is.
🌐
Prisma
prisma.io › home › prisma postgres › prisma postgres › prisma postgres
Quickstart: Prisma ORM with Prisma Postgres (5 min) | Prisma Documentation
August 24, 2022 - Create a new TypeScript project from scratch by connecting Prisma ORM to Prisma Postgres and generating a Prisma Client for database access.
🌐
Patricktree
patricktree.me › blog › how-prisma-adapts-result-types-based-on-the-actual-arguments-given
How Prisma adapts Result Types based on the Actual Arguments given
July 7, 2022 - If so, include OrgUnitGetPayload in the result type (which contains, amongst other things, the properties for the OrgUnit model). If you are curious, you can clone this repository I made and dig through index.d.ts, the type definitions of Prisma Client (generated based on the schema we worked on in this blog post). ... Great, then let's keep in touch! Follow me on Bluesky or on X, I post about TypeScript...