GraphQL in JavaScript: An Introduction
A fundamental intro to GraphQL and how to use it with Express to serve your APIs
This article acts as an introductory to GraphQL, an API query language and runtime, that assumes no prior knowledge from the reader. It breaks down what GraphQL is — and why now is the time to take notice. The benefits it has over traditional REST APIs will be covered, along with the fundamental concepts and tools to get started.
The official GraphQL documentation does a great job at introducing the GraphQL schema and query language syntax, so rather than duplicating the idea of a coding tutorial, this piece will build the reader’s understanding and comprehension of GraphQL.
GraphQL clients are commonly used with Express, where Express provides a single endpoint to access your GraphQL service (with middleware also being supported out of the box). We’ll be using the JavaScript implementation of GraphQL, GraphQL.js, alongside express-graphql
, throughout this piece.
GraphQL is an open specification, and there are indeed other implementations in the realm of JavaScript (such as the Apollo Server) and other languages, that each come with their own characteristics and strengths. However, the GraphQL.js client this piece explores undoubtedly acts as the best entry-point into…