Ads by ProfitSence

Introduction to GraphQL

Last Updated on Wednesday 5th Oct 2022
  • Schema - A special kind of document that describes how a GraphQL endpoint can receive and send information
  • Query Language - The syntax we use to write GraphQL queries that retrieve data from an endpoint

GraphQL is composed of two main parts

  • The query language, which is used to request datas.
  • The framework that processes these queries.

GraphQL is super flexible as a backend.

  • When it comes to developing new APIs, you can start from scratch with a GraphQL server that communicates directly with your database.

GraphQL is unique language allows us to specify the exact format that we want to receive our data in.

					type post {
  id: ID!
  name: String!
  tag: String


As you can see the above schema looks a lot something like JSON, without knowing anything else like GraphQL.

There is Post object will have an ID field, a name field and the a tag field.

GraphQL vs REST

If you've built a modern web application, chances are you've used a REST API at some point.

Let's take, for example, a simple Testing Purpose API which exposes data.

Let's Say we wanted to fetch some information about a specific post enter the following URL and need to send request to server and returns the object.

  "title":"Lorem Ipsum"


Now, let's use the same example to see how GraphQL differs from REST. When querying that endpoint we can include as many or as few fields as we need.

					query {
  postById(id: "1"){


GraphQL Terms

Queries - Queries are what we write to specify the data we want to fetch from a GraphQlserver and how we want that data to look.

Fields - Fields are the properties that make up the shape of our objects.They are the core of GraphQL.

Types - A collection of fields that make up a specific queryable object.