Understanding GraphQL basics and when to use it
As with REST, GraphQL is a means of accessing and modifying remote data over web-based transports. It uses a publicly visible schema, allowing clients to know exactly which entities it can query, which fields can be modified, and so on. This is similar to how OpenAPI describes RESTful APIs. The schema acts as a contract between the client and the service. GraphQL strictly enforces the schema, preventing clients from accessing or modifying entities or fields that are not defined within it. This strictness provides a lot of freedom for developers of both clients and services, which we'll cover later in this section.
GraphQL supports the following operations:
- Queries: Queries are read operations and are analogous to
GET
requests in REST. - Mutations: Mutations are used for modifying data—that is, creating, updating, and/or deleting it.
- Subscriptions: Subscriptions are used so that clients can receive notifications...