GraphQL – Quick Guide (Tutorialspoint.com)

GraphQL is a specification that describes the behavior of the GraphQL server.

It is a set of guidelines on how to handle requests and responses, such as the protocols supported, the data formats accepted by the server, the response formats returned by the server, and so on. The request server that the client makes to GraphQL is called a query. Another important concept of GraphQL is that its transport layer is unknowable.

It can be used with any available network protocol, such as TCP, WebSocket, or any other transport layer protocol. It is also database neutral, so you can use it with relational or NoSQL databases.

GraphQL Server can be deployed using any of the three methods listed below:

  • GraphQL server with database connection
  • GraphQL server that integrates with existing systems
  • Hybrid method

Integrate the GraphQL server that connects to the database

This architecture has a GraphQL server with an integrated database, which is typically used for new projects. Upon receiving the query, the server reads the request payload and retrieves the data from the database. This is called a parsing query. The response returned to the client follows the format specified in the official GraphQL specification.In the figure above, the GraphQL server and database are integrated on one node. The client (desktop/mobile) communicates with the GraphQL server over HTTP. The server processes the request, retrieves the data from the database and returns it to the client.

The GraphQL server integrates with existing systems

This approach is useful for companies with legacy infrastructure and different apis. GraphQL can be used to unify microservices, legacy infrastructure, and third-party apis across existing systems.In the figure above, the GraphQL API acts as an interface between the client and the existing system. The client application communicates with the GraphQL server, which in turn parses the query.

Hybrid method

Finally, we can combine these two approaches to build a GraphQL server. In this architecture, the GraphQL server will parse any requests it receives. It retrieves data from connected databases or integrated apis. This is shown below: