liveBook · Manning

Partial retrieval

As explained in API Design Patterns

Partial retrieval is obtaining only selected portions of a resource or collection rather than its complete representation.

Partial retrieval returns only selected fields from a resource or collection instead of its complete representation. It matters when resources are large, clients have limited hardware, or connectivity makes unnecessary data costly; even small additions multiply across large lists. section 8.1.1

Field masks provide the usual mechanism: a collection of field paths identifies the data a get operation should return. Nested fields and map keys can be addressed, but array elements should not be selected by position or index. section 8.2 section 8.6

Selecting fields from a resource

A client retrieving a large ChatRoom can request only the fields it needs rather than receiving every field. If it needs a nested value, it identifies that path in the field mask; a map entry such as settings["hello.world"] can likewise be addressed without requesting the entire map. section 8.5 section 8.2

Use partial retrieval with these rules:

  • Support it consistently across all resources if the API supports it at all; resource-specific behavior makes standard get methods surprising. section 8.4.1
  • Return all fields when a retrieval mask is omitted, except for exceptionally large or expensive fields that are explicitly documented as opt-in. section 8.3.4
  • Treat field masks as a data-transfer control, not as a SQL-like relationship query; use a relationship-oriented query system such as GraphQL when joining related resources is the real need. section 8.4
Figure 8.1 Using a field mask when retrieving a resource

Shows how a field mask specifies the fields returned during resource retrieval. section 8.2

How API Design Patterns covers it

How deep it goes
Explains field-mask addressing, defaults, consistency, and limits, but stops short of implementing a full query system.
Examples
Uses large resources, limited IoT devices, ChatRoom administrator fields, nested fields, and settings map keys.
What it assumes
Assumes familiarity with API resources and fields while defining field masks and JSON-based field selection.
What you can do after
Apply it via field masks to request selected resource fields while preserving predictable defaults and consistent API behavior.
How it connects
Connects field masks with partial updates, JSON, nested fields, map keys, arrays, and GraphQL.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.