embedding
Including a small copy of a related resource inside a representation, instead of only linking to it.
In more detail
Embedding saves a round trip when a client always needs small, stable related data. It creates a consistency question when the related data changes, and done carelessly it can hide an N+1 query, so link to large, private or fast-changing data instead.
Related terms
- link relation — The name that says what a link means, such as next, author or self, written as rel in a Link header.
- round trip — One journey of a request to a server and its response back, whose time adds directly to how long the caller waits.
- N+1 query problem — A performance bug where code runs one query for a list and then one more query per item, so N items cost N+1 queries.
Taught in
- Sub-resources And Relationships — Modern API Architecture: REST, GraphQL & gRPC
- Partial Responses — Modern API Architecture: REST, GraphQL & gRPC
- Performance Optimization — Modern API Architecture: REST, GraphQL & gRPC