Some of the new age protocols like GraphQL from Facebook and GRPC from Google are now widely getting popular among developers due to their flexibility and ease of use. New-age technology giants have already adopted GraphQL.
GraphQL is an open-source query language for APIs - a new API standard by Facebook. It executes at run-time and fulfills queries with existing data. GraphQL provides a complete data description in API and enables declarative data fetching. This means a client can ask for and retain the data that is required. GraphQL exposes a single endpoint instead of multiple ones, as compared to REST API.
GraphQL is an open-source data query and manipulation language for APIs.
It is gaining popularity because of the following characteristics:
REST APIs are inflexible, making it difficult to keep up with rapidly changing data requirements.
GraphQL solves many challenges and creates greater efficiencies for Dev teams.
GraphQL |
REST API |
---|---|
Teams work in parallel to speed up product development |
Teams have to wait for the back-end team to complete API development to start using them |
No multiple round trips to fetch data |
Multiple round trips to fetch data |
No over fetching and under fetching of data |
Data is over-fetched in the response |
Example: An app needs to display the Name and Title of user posts. The screen should also display the Name of the last three followers.
There is additional data in the REST API response, which is not required.
Fetch the required data using a GraphQL query with a single endpoint.
Here, the GraphQL query provides only the required data in response, resolving the challenges of over-fetching and under-fetching.
GraphQL testing ensures that the schema, queries, and mutations work as
per expectations on the front-end.
We would love to hear your feedback, questions, comments and suggestions. This will help us to make us better and more useful next time.
Share your thoughts and ideas at knowledgecenter@qasource.com