Why GraphQL is the new REST
As Iβve mentioned before,Β GraphQL has become incredibly popular in the last few years . I consider GraphQL to beΒ the Β most exciting thing to happen to APIs - there are aΒ ton Β of benefits to GraphQL and, in fact, Iβd go so far to say as thatΒ GraphQL is the new REST . Itβs not just me, either:Β GraphQL has exploded in popularity , In theΒ State of JavaScript survey ,Β over 60% of respondents Β have mentioned theyβve heard of GraphQL and are interested in learning it. Iβve used GraphQL for years, and hereβs just a few reasons why GraphQL is aΒ game changer Β in application development today: With GraphQL, no longer will we ever need to make a request from the client for a specific set of data, but where a large amount is unnecessarily returned. Before we tell our GraphQL API how we want each field in our API to be resolved, weβll need to tell GraphQL theΒ type Β of the resolved values of each of the fields. This allows GraphQL to provideΒ descriptive Β error messages when a query fails based on an incorrect value type. Since GraphQL and TypeScript areΒ both Β strongly typed languages, they workΒ incredibly Β well together. In fact, numerous tools exist (like theΒ Apollo Command Line Interface ) which allow us toΒ automatically Β generate TypeScript definitions from a GraphQL API. Many different tools currently exist around working with GraphQL but none weβve come across as powerful as theΒ Apollo Platform . Among a suite of many different tools exists theΒ Apollo Server Β package where a production-ready and intuitive GraphQL API can be built within a Node.js application. The Apollo Client library also exists to allowΒ React Β applications to fetch data from a GraphQL API with complete state management and in a declarative manner (with Hooks!). Tons of organizations have started to adopt GraphQL to power their large scale websites and mobile apps. Here are some recent examples of the many different organizations adopting GraphQL.