liveBook · Manning

Related resource

As explained in API Design Patterns

A related resource is an API resource connected to a target resource through a reference without necessarily being nested beneath it.

A related resource connects to a target through a reference without necessarily being nested beneath it. Its relationship creates design questions when the target is copied or moved. section 17.3.3

Message review reports

A chat API can model an inappropriate-message report as MessageReviewReport. Its messageId references a Message, although the report is not necessarily a child of that Message or its ChatRoom. Copying a Message raises whether its reports should also be duplicated; moving it raises whether those references must be updated. section 17.3.3

Account for these consequences when designing copy and move behavior:

  • Preserve referential integrity during moves by updating references so they do not point to an invalid resource. section 17.3.3
  • Choose explicitly whether copying a target also copies related resources; there is no single correct policy for every scenario. section 17.3.3
  • Consider indirect operations, because copying or moving a parent can cascade to the target without a direct request against it. section 17.3.3
Listing 17.4 A MessageReviewReport resource that references a Message resource
interface MessageReviewReport {
  id: string;
  messageId: string;     #1
  reason: string;
}

Inspect the compact resource shape showing a reference from MessageReviewReport to Message. section 17.3.3

How API Design Patterns covers it

How deep it goes
Explains reference integrity and decision points, but stops short of prescribing one universal copy policy or implementation.
Examples
Uses MessageReviewReport with a messageId reference to demonstrate copying, moving, and indirect ChatRoom operations.
What you can do after
Evaluate copy and move policies for referenced resources while preserving referential integrity during moves.
How it connects
Connects related resources with resource copying, resource moving, cascading operations, and referential integrity.

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.