Introduction to GraphQL for Developers

GraphQL is a powerful query language for APIs and a runtime for resolving queries with data.

Coder Society
Nov 24, 2020 · 9 min read

In this article, we’ll explore GraphQL’s core features, how to interact with a GraphQL API, and some development and operational challenges.

Image for post
Image for post
Source: Coder Society

The Story of GraphQL

Features of GraphQL

Working with GraphQL

$ git clone
$ cd starwars-server$ npm install
$ npm start
Image for post
Image for post
Figure 1: Exploring the API via GraphQL Playground’s “Docs” tab


query {humans {idname}}
{"data": {"humans": [{"id": "1000","name": "Luke Skywalker"},{"id": "1001","name": "Darth Vader"},{"id": "1002","name": "Han Solo"},{"id": "1003","name": "Leia Organa"},{"id": "1004","name": "Wilhuff Tarkin"}]}}
query {human (id: 1001) {homePlanet}}
{"data": {"human": {"homePlanet": "Tatooine"}}}
Image for post
Image for post
Figure 2: GraphQL Playground suggests fields you can include as you type
query {human(id: 1001) {homePlanetnameappearsInstarships {idname}}}
{"data": {"human": {"homePlanet": "Tatooine","name": "Darth Vader","appearsIn": ["NEWHOPE","EMPIRE","JEDI"],"starships": [{"id": "3002","name": "TIE Advanced x1"}]}}}

Mutations and Subscriptions

subscription {reviewAdded {episodestarscommentary}}
mutation {createReview(episode: NEWHOPE, review: {stars: 5,commentary: "Awesome"}) {episodestarscommentary}}
{"data": {"createReview": {"episode": "NEWHOPE","stars": 5,"commentary": "Awesome"}}}
Image for post
Image for post
Figure 3: Reviews are pushed to a subscription in GraphQL Playground

GraphQL in the Real World





Other Considerations

Wrapping Up


JavaScript news and opinion.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store