Querying Related Data in the payload

When fetching data via Payload’s REST or GraphQL API, related fields can be populated using depth in the query.

REST API Example:

GET /api/users?depth=2

This ensures related fields are expanded up to two levels deep.

GraphQL Example:

query {
 Users {
  docs {
   name
   profile {
    bio
    avatar
   }
  }
 }
}

Leave a comment

Your email address will not be published. Required fields are marked *