Learning GraphQL: Declarative Data Fetching for Modern Web Apps

Learning GraphQL: Declarative Data Fetching for Modern Web Apps

by Eve Porcello, Alex Banks
Learning GraphQL: Declarative Data Fetching for Modern Web Apps

Learning GraphQL: Declarative Data Fetching for Modern Web Apps

by Eve Porcello, Alex Banks

Paperback

$45.99 
  • SHIP THIS ITEM
    Qualifies for Free Shipping
  • PICK UP IN STORE
    Check Availability at Nearby Stores

Related collections and offers


Overview

Why is GraphQL the most innovative technology for fetching data since Ajax? By providing a query language for your APIs and a runtime for fulfilling queries with your data, GraphQL presents a clear alternative to REST and ad hoc web service architectures. With this practical guide, Alex Banks and Eve Porcello deliver a clear learning path for frontend web developers, backend engineers, and project and product managers looking to get started with GraphQL.

You'll explore graph theory, the graph data structure, and GraphQL types before learning hands-on how to build a schema for a photo-sharing application. This book also introduces you to Apollo Client, a popular framework you can use to connect GraphQL to your user interface.

  • Explore graph theory and review popular graph examples in use today
  • Learn how GraphQL applies database querying methods to the internet
  • Create a schema for a PhotoShare application that serves as a roadmap and a contract between the frontend and backend teams
  • Use JavaScript to build a fully functioning GraphQL service and Apollo to implement a client
  • Learn how to prepare GraphQL APIs and clients for production

Product Details

ISBN-13: 9781492030713
Publisher: O'Reilly Media, Incorporated
Publication date: 09/03/2018
Pages: 196
Sales rank: 926,659
Product dimensions: 6.90(w) x 9.10(h) x 0.50(d)

About the Author

Alex Banks and Eve Porcello are software engineers/architects, Lynda.com authors, instructors, and founders of Moon Highway. They have developed customized training curriculum on proprietary and open-sourced solutions. Alex and Eve teach JavaScript throughout the country at places including Yahoo!, eBay, PayPal, Stanford University, Macys.com, Starbucks, vmware, and many more.




They also are active in the JavaScript community as the co-founders of Reacto: The Sacramento React.js Meetup and members of the San Francisco React.js Meetup.

Table of Contents

Preface vii

1 Welcome to GraphQL 1

What Is GraphQL? 2

The GraphQL Specification 4

Design Principles of GraphQL 5

Origins of GraphQL 5

History of Data Transport 6

Remote Procedure Call 6

Simple Object Access Protocol 6

REST 7

REST Drawbacks 7

Overfetching 8

Underfetching 9

Managing REST Endpoints 11

GraphQL in the Real World 12

GraphQL Clients 12

2 Graph Theory 15

Graph Theory Vocabulary 18

History of Graph Theory 20

Trees are Graphs 24

Graphs in the Real World 27

3 The GraphQL Query Language 31

GraphQL API Tools 33

GraphiQL 33

GraphQL Playground 36

Public GraphQL APIs 38

The GraphQL Query 38

Edges and Connections 41

Fragments 43

Mutations 48

Using Query Variables 50

Subscriptions 51

Introspection 52

Abstract Syntax Trees 53

4 Designing a Schema 57

Defining Types 57

Types 58

Scalar Types 59

Enums 59

Connections and Lists 60

One-to-One Connections 61

One-to-Many Connections 62

Many-to-Many Connections 64

Lists of Different Types 66

Arguments 68

Filtering Data 69

Mutations 72

Input Types 74

Return Types 77

Subscriptions 78

Schema Documentation 79

5 Creating a GraphQL API 83

Project Setup 83

Resolvers 84

Root Resolvers 86

Type Resolvers 88

Using Inputs and Enums 91

Edges and Connections 93

Custom Scalars 97

Apollo-server-express 102

Context 104

Installing Mongo 104

Adding Database to Context 105

GitHub Authorization 107

Setting Up GitHub OAuth 108

The Authorization Process 111

GithubAuth Mutation 112

Authenticating Users 115

Conclusion 121

6 GraphQL Clients 123

Using a GraphQL API 123

Fetch Requests 123

Graphql-request 125

Apollo Client 128

Apollo Client with React 128

Project Setup 129

Configure Apollo Client 129

The Query Component 131

The Mutation Component 135

Authorization 137

Authorizing the User 137

Identifying the User 141

Working with the Cache 143

Fetch Policies 143

Persisting The Cache 144

Updating the Cache 145

7 GraphQL in the Real World 149

Subscriptions 150

Working with Subscriptions 150

Consuming Subscriptions 156

Uploading Files 160

Handling Uploads on the Server 160

Posting a New Photo with Apollo Client 162

Security 168

Request Timeouts 169

Data Limitations 169

Limiting Query Depth 170

Limiting Query Complexity 172

Apollo Engine 174

Taking the Next Steps 175

Incremental Migration 175

Schema-First Development 176

GraphQL Events 178

Community 179

Community Slack Channels 180

Index 181

From the B&N Reads Blog

Customer Reviews