GraphQL vs REST APIs
GraphQL vs REST APIs
REST is a ubiquitous and very serviceable client-server API specification across the industry. REST allows a client application to act on a remote resource using the HTTP-standard actions of POST, GET, PUT, and DELETE to perform the standard CRUD operations on a URL-specified resource. GraphQL is client-server API specification that allows a client application to act on remote resources over HTTP where actions are specified within content of the HTTP request.
REST APIs can Overfetch
REST is resource-oriented and requires an API invocation for each resource to be fetched. For example, retrieving the details of a list of objects or related objects may each require a new invocation. REST also fetches the full set of attributes as specified by the API. Both of these features negatively impact performance. The first introduces chatty communications. The second over-fetches data that may be of no interest to the client application.
GraphQLs are Efficient
GraphQL takes a completely different approach. GraphQL presents a schema of the underlying resources where the client application sends queries or updates to the API. With a single API invocation, the client application is able to access not only multiple resources but the specific attributes of interest within a resource and under what criteria. The flexibility of allowing the client to dictate its interests improves performance and simplifies the overall API implementation by decoupling the implementation from client request variations.