Introduction

This course is an introduction to GraphQL, Apollo Server and Apollo Client. We'll first have a quick intro into what GraphQL is, then build a small server using Apollo Server and see how we can fetch data from it for our front end using Apollo Client.

Since at Codegram we use GraphQL in a lot of our projects, this course is designed to give you an overview of it from both a server side and front end perspective.

Requirements

Intro

What is GraphQL?

Even if you don't know what GraphQL is, chances are you've at least heard of it seeing as it's become somewhat of a buzzword over the last few years. As described in the docs, GraphQL is "a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data". In short it's a way for the client to query the server by stating exactly what data they want in return, and they will receive this, and only this. Nothing more and nothing less. I have previously written a blogpost on the basics of what GraphQL is and how it can be beneficial over REST. Go on over to the blogpost for a intro before continuing with the workshop.

My journey into GraphQL (part 1) - GraphQL 101

Part 1

Let's get started

So now you have an idea of what GraphQL is, let's go ahead and start using it! The first thing we're going to do is get stuck in and build a small server using Apollo Server. Apollo Server is a library for building a GraphQL server in JavaScript. It provides a powerful GraphQL IDE, GraphQL Playground, that lets you interactively work with your GraphQL API. Think of it like Postman, but specifically for GraphQL. Although you may or may not be using JavaScript in your project, the aim of this course is to give an overview of how GraphQL works which can then be translated to other libraries and languages.

So let's get stuck in! We will need a Node.js project to start with but don't worry, I have created a Node.js repository with Babel for us to work from here. Fork and clone the repository and head on over to index.js in your editor.

To start building our server we need to install apollo-server and graphql.