Search
Star
Feedback
Setup for Free
© 2026 Hedgehog Software, LLC
Twitter
GitHub
Discord
System
Light
Dark
More
Communities
Docs
About
Terms
Privacy
$extends(withAccelerate()) breaks type inference when orderBy is used inside nested includes - Prisma
P
Prisma
•
3mo ago
•
5 replies
davidpink
$extends(withAccelerate()) breaks type inference when orderBy is used inside nested includes
Accelerate
Prisma Postgres
Description
:
Environment
:
- Prisma
: 7
.2
.0
-
@prisma
/extension
-accelerate
: 3
.0
.1
- TypeScript
: 5
.9
.3
- Framework
: Next
.js
+ tRPC
Setup
(per docs
)
:
`
`
`ts
import
{ PrismaClient
} from
"
@prisma
/client
"
;
import
{ withAccelerate
} from
"
@prisma
/extension
-accelerate
"
;
export const prisma
= new PrismaClient
(
{
accelerateUrl
: process
.env
.DATABASE
_URL
,
}
)
.
$extends
(withAccelerate
(
)
)
;
Bug
:
When using orderBy inside a nested include
, all type inference for that query breaks
. The return type loses all included relations
.
Reproduction
:
/
/
BROKEN
- orderBy inside nested include
const result
= await prisma
.membership
.findFirst
(
{
include
:
{
prices
:
{
where
:
{ status
:
"ACTIVE
"
}
,
orderBy
:
{ createdAt
:
"desc
"
}
,
/
/
<
-
- This breaks inference
take
: 1
,
}
,
}
,
}
)
;
result
.prices
/
/ Error
: Property
'prices
' does not exist
/
/
WORKS
- same query without orderBy
const result
= await prisma
.membership
.findFirst
(
{
include
:
{
prices
:
{
where
:
{ status
:
"ACTIVE
"
}
,
take
: 1
,
}
,
}
,
}
)
;
result
.prices
/
/
Type
: Price
[
]
Impact
:
- 1000
+ type errors across codebase
- All tRPC RouterOutputs types break
- Nested type derivations fail completely
Workaround
:
Remove orderBy from nested includes and sort in JS after fetching
.
Prisma
Join
The official Discord server of Prisma! Find us online at prisma.io
9,819
Members
View on Discord
Resources
ModelContextProtocol
ModelContextProtocol
MCP Server
Similar Threads
Was this page helpful?
Yes
No
Recent Announcements
Similar Threads
Nested orderBy
P
Prisma / help-and-questions
2y ago
Application breaks when adding .$extends to prisma initialziation
P
Prisma / help-and-questions
2y ago
Prisma type inference is returning weird types
P
Prisma / help-and-questions
2y ago