Sitemap

Member-only story

Introduction to GraphQL

Part 1: From REST API to GraphQL

6 min readAug 6, 2024

--

GraphQL was developed by Facebook in 2012 and was released as an open-source project in 2015. It has since become a popular alternative to REST APIs, especially for complex data-fetching scenarios.

Press enter or click to view image in full size
This image was created using an AI image creation program.

What is GraphQL?

GraphQL is a query language for our API and a server-side runtime for executing queries using a type system we define for our data.

Terminologies

  • Schema: The core of any GraphQL service, defining the types and the relationships between them.
  • Query: A read-only fetch operation.
  • Mutation: A write operation that allows us to insert, update, or delete data.
  • Subscription: Allows clients to subscribe to real-time updates.
  • Resolvers: Functions that handle fetching the data for each type in a schema.

💡 The correct term for the component that defines and serves the GraphQL schema is typically called the GraphQL Server or API Server.

Example from Octopus Energy API:

query EnergyProductQuery($productCode: String!) {
energyProduct(code: $productCode) {
code
fullName
displayName
description
term
}
}

--

--

Ryan W
Ryan W

Written by Ryan W

Modern Android Development | Ethical AI | Independent UK↔HK Technologist