



How REST Replicates GraphQL Benefits (Without the Drawbacks)
If you prefer to stay on a REST architecture but want to solve the over-fetching and under-fetching issues that GraphQL usually handles, you can implement these patterns:
· Sparse Fieldsets (JSON:API Standard)
o The Pattern: You can allow clients to dynamically filter fields via URL query parameters.
o Example: GET /users/123?fields=id,name,email tells the REST server to only serialize those specific three keys, preventing over-fetching.
· Resource Embedding (Hal / Compound Documents)
o The Pattern: To fix under-fetching and prevent multiple network round-trips, endpoints can accept an include parameter to side-load related data structures in a single response.
o Example: GET /orders/456?include=items,shipping_address fetches the order, its nested items, and the address altogether in one HTTP round-trip.