depth controls how many levels of relationships Payload expands — and it's a runtime decision, not something baked into your schema.
The same document can come back "flat" or with its relationships populated, driven by a single query parameter:
// depth: 0 -> author is just an ID
{ id: '1', title: 'Hi', author: '64a...' }
// depth: 1 -> author is a full object
{ id: '1', title: 'Hi', author: { id: '64a...', name: 'Ada' } }
await payload.findByID({ collection: 'posts', id, depth: 2 })
And when you want to limit which fields get populated as a document is expanded from another document, reach for defaultPopulate on the collection — so you're not dragging entire heavy documents along for the ride.
Tune depth per query and you control your payload size without touching the data model.
Top comments (0)