Skip to main content

Posts

Showing posts with the label GraphQL

Why all API enthusiasts should know about GraphQL?

With GraphQL, what you queried is what you get, nothing more and nothing less. It is easy to use as it has a JSON like syntax and also provides lots of performance benefits. Here's a query for the Star Wars API: https://swapi.apis.guru/graphiql query{ allFilms { films { id title episodeID } } } This query returns the id, title, and episodeID of the 6 original Star Wars movies. Now consider that there are 2 vendors that are consuming this API and one of them wants id, title, and episodeID and the other one wants the only id, and title but NOT the episodeID. Now without GraphQL, we would have created 2 versions of this API i.e. the first one with the id, title, and episodeID in the response and the second version giving a response with id and title only. Isn't it a headache to maintain so many versions if you have different requests from various vendors that are consuming your APIs? That's where a GraphQL is a real lifesaver. Please check graphQLComplete method shown