GraphQL is a way to build a Web API. It defines specifications for the type system, query language, and schema language for Web apis. The GraphQL service (or engine) gives you the flexibility to build the query execution algorithm.

Why GraphQL

GraphQL was developed to reuse the same API. GraphQL works with API clients with different requirements, without changing the implementation when the server adds a new client or changing the way the client uses the API when it adds new content. It addresses many of the inefficiencies you might encounter when using REST apis.

Some of the reasons GraphQL should be used when building apis are:

  • GraphQL API strongly typed schemas can use the GraphQL Schema Definition Language (SDL). GraphQL definitions are written that explicitly define what operations the API can perform and what types are available. This pattern is used by the server’s validation engine to validate requests from clients to determine whether they can be executed.
  • No more excess or deficiency because it defines a set of query syntax, so clients can request data of any shape they want, as long as these types and their fields are defined in the schema. This is similar to REST APIS, where endpoints return predefined and fixed data structures.
  • GraphQL uses the resolver function to determine the data returned by fields and types in the schema. Because the client can select the fields that the server should return with the response, you can track how these fields are used and improve the API to discard fields that the client no longer requires.

2, use,