What is GraphQL?
       GraphQL is a query language for APIs. It was developed by Facebook as a solution to fetch data more efficiently.

Why GraphQL:
     The Problems with REST In REST APIs, each endpoint will return a specific payload of JSON data. Even if we only need certain fields, it will return everything on every request. REST APIs have multiple endpoints, but GraphQL provides a single endpoint.

How GraphQL Works
      GraphQL fetches only the data you need using queries. With GraphQL, there is:

  1. No overfetching or underfetching
  2. Less endpoints to manage (i.e., only /graphql)
  3. Flexible integration with databases, REST APIs, cloud services, and JSON files.

      Queries are entry points on a GraphQL server that provide read access to your data sources. GraphQL queries allow clients to dictate the fields they want and the response structure, similar to the GET method in REST APIs. For example:

query Query {

getStudentdetails {





This query retrieves student details.

      Mutations in GraphQL are used to modify data on the server. Equivalent to POST requests in REST, mutations enable clients to create, update, or delete data. While mutations are similar to queries in syntax, they are specifically designed for altering backend data. For example:

mutation Mutation($Studentname: String!, $phoneNumber: String!, $address: String) {

  Studentdetail(Studentname: “bharath”, phoneNumber: “1234567890”, address: “Tamilnadu”) {





This mutation adds student details to the database.

Leave a Reply