Home
+91 99674 50288
info@appmonks.net
×

GraphQL


 

GraphQL is query language for API and a runtime for fulfilling those queries with your existing data.GraphQL provides a complete and understandable description of the data in your API gives client the power to ask exactly what they need nothing more,makes it easier to evolve APIs over time and enables power developer tool.GraphQL is a query language and server-side runtime for application programming interfaces (APIs) GraphQL was developed internally by Facebook in 2012 before being publicly released in 2015.

GraphQL is designed to make APIs fast, flexible, and developer-friendly. It can even be deployed within an integrated development environment (IDE) known as GraphQL. GraphQL is not only for React Developers.

Additionally, GraphQL gives API maintainers the flexibility to add or deprecate fields without impacting existing queries.

Why is it called GraphQL?

• You could represent the data in your application with a graph of nodes and edges.

• The nodes represent objects.

• The edges represent relationships between these objects.

Why GraphQL?

RESTful APIs follow clear and well-structured resource-oriented approach. However, when the data gets more complex, the routes get longer. Sometimes it is not possible to fetch data with a single request. This is where GraphQL comes handy. GraphQL provides exact data.

Example

Request

{

orders {

id

products {

product {

name

price

}

quantity

}

totalAmount

}

}

Response

{

"data": {

"orders": [

{

"id": 1,

"products": [

{

"product": {

"name": "Iphone XR,

"price": 38000

},

"quantity": 10

}

],

"totalAmount": 380000

}

]

}

}

Advantage

• GraphQL calls are handled in a single round trip. Clients get what they request with no overfetching.

• Strongly defined data types reduce miscommunication between the client and the server.

• GraphQL allows an application API to evolve without breaking existing queries.

Disadvantage

• Caching is more complex than with REST.

• Another problem is rate limiting.whereas in REST it is simpler to say ” we allow only so many requests in one day” it becomes difficult to make such a statement for individual GraphQL operation because it can be everything between a cheap or expensive operation.

• GraphQL shifts much of the work of a data query to the server side, which adds complexity for server developers.


Mail
casino