
This move to GraphQL marked a larger shift in our platform strategy to be more transparent and flexible. You can defer data, where you choose to mark a part of your response as time-insensitive.You can create subscriptions, where your client can receive new data when it becomes available.You can batch requests, where you define dependencies between two separate queries and fetch data efficiently.
An insight into the required scopes could ensure that only the appropriate types are being requested.A mobile app based on GraphQL could simplify its requests by only asking for the data it needs.) Depending on a business need, you sometimes need to send just a general section, sometimes a detailed pitch. For example, you have an entity that describes an offer visualised on several screens. (This type of design makes it possible to use clients where smaller payload sizes are essential. You let the client decide which data it needs to download.Some of the arguments that spoke for this change, were: Therefore, we decided to refactor the API to leverage GraphQL. to generate clients instead of manually supplying patches to our Octokit suite.
GRAPHQL VS REST VS GRPC CODE
to generate documentation from our code. to be smarter about how our resources were paginated to assure type-safety for user-supplied parameters. For example, we wanted to identify the OAuth scopes required for each endpoint. What’s more, we wanted to collect some meta-information about our endpoints. It seemed like our responses simultaneously sent too much data and didn’t include data that consumers needed. It sometimes required two or three separate calls to assemble a complete view of a resource. Why do it if GraphQL is already there?Īt Objectivity, we had a GitHub API based on REST, but despite all the information we provided through it, we heard from integrators that our API wasn’t very flexible. Although you can do almost anything using REST API, the effort of implementing some functionalities is not worth it. REST is a go-to solution for some uses, but in other cases it’s too rigid. Because of the data structures, it is difficult to know exactly what kind of information each client typically needs. This stifles the possibility of rapidly cycling through different front-end iterations. Commonly REST endpoints are structured according to the needs of your app. To fulfill a complex query that fetches data according to some relationships, you have to create multiple requests and build the related data into the initial response (or modify URLs). This can result in over- and under-fetching. To fetch data, you typically need to access multiple endpoints with fixed data structures. Indeed, why? REST is versatile and doing well, so why bother with rewriting your applications or changing the architecture of future projects? Well, like most technologies, REST is not perfect and has some drawbacks.
The cool thing about it is that it allows to fulfill queries by using a type system you define for your data. Simply put, GraphQL is a query language for APIs and a server-side runtime.