Skip to Content
JavaScript Everywhere
book

JavaScript Everywhere

by Adam D. Scott
February 2020
Intermediate to advanced
344 pages
6h 37m
English
O'Reilly Media, Inc.
Content preview from JavaScript Everywhere

Chapter 4. Our First GraphQL API

Presumably, if you are reading this, you are a human being. As a human you have a number of interests and passions. You also have family members, friends, acquaintances, classmates, and colleagues. Those people also have their own social relationships, interests, and passions. Some of these relationships and interests overlap, while others do not. All together, we each have a connected graph of the people in our lives.

These types of interconnected data are exactly the challenge that GraphQL initially set out to solve in API development. By writing a GraphQL API we are able to efficiently connect data, which reduces the complexity and number of requests while allowing us to serve a client precisely the data they need.

Does that all sound like a bit of overkill for a notes application? Perhaps it does, but as you’ll see, the tools and techniques provided by the GraphQL JavaScript ecosystem both enable and simplify all types of API development.

In this chapter we’ll build a GraphQL API, using the apollo-server-express package. To do so, we’ll explore fundamental GraphQL topics, write a GraphQL schema, develop code to resolve our schema functions, and access our API using the GraphQL Playground user interface.

Turning Our Server into an API (Sort Of)

Let’s begin our API development by turning our Express server into a GraphQL server using the apollo-server-express package. Apollo Server is an open source GraphQL server library that works with a large ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

The Modern JavaScript Bootcamp (2019)

The Modern JavaScript Bootcamp (2019)

Andrew Mead
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 9781492046974Errata PageSupplemental Content