APIs
REST Architectural Constraints
| Name | Description |
|---|---|
| Client-Server (Decoupling) | Separation of concerns between the client and server, allowing them to evolve independently and improve scalability, reliability, and portability. |
| Stateless | Each request from the client to the server must contain all the information necessary to understand and fulfill the request, meaning no client context is stored on the server between requests. |
| Cacheability | Responses must define themselves as cacheable or non-cacheable, improving efficiency, scalability, and user-perceived performance through the use of caching. |
| Uniform Interface | A uniform and standardized way of interacting with resources through well-defined operations (HTTP methods) and resource representations (media types). |
| Layered System | A hierarchical system where intermediaries (proxies, gateways, etc.) can be used to improve scalability, security, and encapsulation by providing additional layers of abstraction. |
| Code-On-Demand (Optional) | Servers can temporarily extend the functionality of a client by transferring executable code (e.g., JavaScript) within a response, enhancing flexibility and reducing client-server coupling. |
Note
REST = REpresentational State Transfer
REST Methods
| Method | CRUD Operation |
|---|---|
| POST | Create |
| GET | Read |
| PUT | Update |
| PATCH | Specific-Update |
| DELETE | Delete |
GraphQL
| Name | Description |
|---|---|
| Schema | Defines the structure of the data in the GraphQL API, including types, fields, and relationships. |
| Query | Defines how clients can fetch data from the GraphQL server. Queries are used to retrieve data from the server. |
| Mutation | Defines how clients can modify data on the GraphQL server. Mutations are used to create, update, or delete data. |
| Subscription | Defines how clients can subscribe to real-time data updates from the GraphQL server. Subscriptions allow clients to receive data as it changes. |
| Resolver | Functions that define how GraphQL fields are resolved. Resolvers are responsible for fetching the data associated with each field. |
| Scalar | Primitive data types in GraphQL that represent single values, such as integers, strings, booleans, and floats. |
| Type | Composite data types in GraphQL that represent complex objects with multiple fields. Object types define the structure of the data returned by queries and mutations. |
| Input | Similar to object types, input types represent complex input data for mutations. Input types define the structure of the data that clients can provide when executing mutations. |
| Enum | An enumeration type in GraphQL that represents a predefined set of possible values. Enums are used to define a specific domain of valid options for a field. |
| Union | A type in GraphQL that represents a combination of one or more object types. Unions allow for flexibility in query responses by allowing a field to return different types of objects. |
| Interface | A type in GraphQL that defines a common set of fields that multiple object types can implement. Interfaces enable polymorphism and ensure consistent field structures across related types. |