04. HTTP Servers, REST and GraphQL

Databases, JS behavior, REST versioning

REST

A REST service is a platform and language independent service that runs on top of HTTP(S).

REST services use the same HTTP verbs used by web browsers and hence, they can be thought of as a subset of web apps.

HTTP/REST resources usually have a unique identifier (e.g. integer. UUID). Often, the structure of the URL mirrors the structure of the data.

Misc:

URLs:

State timescales (shortest to longest):

Session state:

HTTP

Stateless protocol; each request/response self-contained.

Safe methods (nullipotentcy): methods that do not modify resources. GET and HEAD are safe.

Idempotent methods: intended state is the same regardless of how many times the method is called. POST and PATCH are not idempotent.

The lack of side effects helps in making the API more fault tolerant

CAP Theorem

In theory, you can have two of the three. However, networks fail (which you have no control over) so you must tolerate partitioning.

API Versioning

Ensure compatibility between the API provider and users. Adding new features may not require new versions, but removing or amending features will require a new version.

Versions may be useful for:

From a client perspective, an API is backwards compatible if it it can continue to function through a service change (e.g. adding new features) and forwards compatible if the client can be changed without needing a service change.

Semantic Versioning

MAJOR.MINOR.PATCH:

Encoding Versioning

Publishing