12.6 · REST, GraphQL and gRPC, and building a client platform
The protocol choice is mostly a server decision with client consequences. The platform question is how a dozen features share one disciplined way of talking to the network.
Mental model. Choose the shape of the API by what clients need to fetch, and build one client layer that every feature goes through.
Styles and platform
API styles from the client side, and building a client for many apps.
- REST, GraphQL or gRPC: what are the client-side trade-offs?
REST models resources at URLs and uses HTTP verbs and status codes. For a client it is simple, uses plain URLSession and Codable, benefits fully from HTTP… - How would you design a networking layer shared by many apps and teams: interceptors, mocking, and URLProtocol?
A shared client should be one small layer with a narrow public API and everything else configurable behind it. Start from a URLSession per configuration, owned…
More in Networking
- 12.1 · Sessions, configurations, tasks, delegates and background transfers
- 12.2 · HTTP versions, TLS, App Transport Security and certificate pinning
- 12.3 · Pagination, caching and conditional requests, and authentication refresh
- 12.4 · WebSockets, multipart and large transfers, and network path monitoring
- 12.5 · Retries, backoff, idempotency and cancellation
- 12.7 · Image loading pipelines: download, decode, downsample, cache
- 12.8 · Building URLs, reading headers, classifying errors and timeouts
- 12.9 · Single-flight token refresh, streaming lines, multipart bodies and request signing
- 12.10 · Network.framework, background sessions, delegates versus async, diagnosing and measuring