GraphQL in Action
Samer Buna
  • ISBN 9781617295683
  • 375 pages (estimated)
  • printed in black & white

Provides a great overview to GraphQL. The explanations are clear and the code examples are extremely relevant.

Dary Merckens
Reduce bandwidth demands on your APIs by getting only the results you need—all in a single request! The GraphQL query language simplifies interactions with web servers, enabling smarter API queries that can hugely improve the efficiency of data requests. In GraphQL in Action, you’ll learn how to bring those benefits to your own APIs, giving your clients the power to ask for exactly what they need from your server, no more, no less. Practical and example-driven, this book teaches everything you need to get started with GraphQL—from design principles and syntax right through to performance optimization.

About the Technology

The type-based GraphQL query language solves issues with over- or under-fetching data from an API, providing client apps with a predictable interface for interacting with a server. By organizing data as types and fields, GraphQL gives apps complete control over what they’re requesting, including data format, how much to fetch, and more. The result is faster transfer roundtrips, errors that are easier to spot, and virtually no need for clients to write time-consuming manual parsing code. Language-agnostic, GraphQL can be used with any language and incorporated easily into your existing stack.

About the book

In GraphQL in Action, you’ll learn to use GraphQL to simplify interactions with your web servers and improve the performance of your data APIs. Twenty-year web development veteran Samer Buna starts by introducing GraphQL’s unique query-based API paradigm, laying out its unique design concepts and advantages over traditional APIs. From there, you’ll master the GraphQL way of creating APIs for hierarchical data, unlock easy ways to incorporate GraphQL into your existing codebase, and learn how to consume a GraphQL API with queries, mutations, and subscriptions using the GraphQL query language. When you’re done, you’ll have all the skills you need to get started writing and using scalable data APIs with GraphQL. GraphQL is a new paradigm. Are you ready?
Table of Contents detailed table of contents

Part 1: Exploring GraphQL

1 Introduction to GraphQL

1.1 What is GraphQL

1.1.1 The big picture

1.1.2 GraphQL is a specification

1.1.3 GraphQL is a language

1.1.4 GraphQL is a service

1.2 Why GraphQL

1.2.1 What about REST APIs?

1.2.2 The GraphQL way

1.2.3 REST APIs and GraphQL APIs in action

1.3 GraphQL problems

1.3.1 Security

1.3.2 Caching and optimizing

1.3.3 Learning curve

1.4 Summary

2 Exploring GraphQL APIs

2.1 The GraphiQL editor

2.2 The basics of the GraphQL language

2.2.1 Requests

2.2.2 Fields

2.3 Examples from the GitHub API

2.3.1 Reading data from GitHub

2.3.2 Updating data at GitHub

2.3.3 Introspective queries

2.4 Summary

3 Customizing and organizing GraphQL operations

3.1 Customizing fields with arguments

3.1.1 Identifying a single record to return

3.1.2 Limiting the number of records returned by a list field

3.1.3 Ordering records returned by a list field

3.1.4 Paginating through a list of records

3.1.5 Searching and filtering

3.1.6 Providing input for mutations

3.2 Renaming fields with aliases

3.3 Customizing responses with directives

3.3.1 Variables and input values

3.3.2 The @include directive

3.3.3 The @skip directive

3.3.4 The @deprecated directive

3.4 GraphQL fragments

3.4.1 Why fragments?

3.4.2 Defining and using fragments

3.4.3 Fragments and DRY

3.4.4 Fragments and UI components

3.4.5 Inline fragments for interfaces and unions

3.5 Summary

Part 2: Building GraphQL APIs

4 Designing a GraphQL schema

4.1 Why AZdev

4.2 The API requirements for AZdev

4.2.1 The core types

4.3 Queries

4.3.2 Search and the union/interface types

4.3.3 Using an interface type:

4.3.4 The page for one Need record

4.3.5 Entity relationships

4.3.6 The ENUM type

4.3.7 The page for a user’s own Need records

4.3.8 Authentication and authorization

4.4 Mutations

4.4.1 Mutations input

4.4.2 Creating and Updating a Need

4.4.3 Creating and voting on Approach entries

4.5 Full schema text

4.6 Summary

5 Implementing Schema Resolvers

5.1 Node.js Drivers for PostgreSQL and MongoDB

5.1.1 Installing Dependencies

5.1.2 Environment Variables

5.1.3 Connecting To Databases

5.1.4 Loading Seed Data

5.2 Setting up a GraphQL Runtime

5.2.1 Creating the Schema Object

5.2.2 Creating Resolver Functions

5.2.3 Executing Requests

5.3 Communicating Over HTTP

5.4 Building a Schema Using Constructor Objects

5.4.1 Auto-restarting Node

5.4.2 The Top-level Query Type

5.4.3 Field Arguments

5.4.4 Custom Object Types

5.4.5 Custom Errors

5.5 Objects To Schema Language Conversion

5.5.1 The full-schema text vs the object-based methods

5.6 Working with Asynchronous Functions

5.7 Summary

6 Resolving Database Models and Relations

6.1.1 Defining Object Types

6.1.2 The Context Object

6.1.3 Transforming Field Names

6.1.4 Transforming Field Values

6.1.5 Separating interactions with PostgreSQL

6.2 Resolving Relations

6.2.1 Resolving a One-to-One Relation

6.2.2 Resolving a One-to-Many Relation

6.3 Summary

7 Optimizing Data Fetching

7.1 Caching and Batching

7.1.1 The batch loading function

7.1.2 Defining and Using a DataLoader Instance

7.1.3 Adding Loader for Approaches

7.2 Using DataLoader with Custom IDs for Caching

7.2.1 The neadFeaturedList field

7.2.2 The search field

7.3 Using DataLoader with MongoDB

7.4 Single Resource Fields

7.5 The viewer Field

7.5.1 The needList Field

7.5.2 Dynamic Types

7.6 Summary

8 Implementing Mutations

8.1 The mutators Context Object

8.2 The Root Mutation Type

8.3 User Mutations:

8.3.1 The userCreate Mutation

8.3.2 The userLogin Mutation

8.4 Need Mutations

8.4.1 The needCreate Mutation

8.4.2 The needUpdate Mutation

8.5 Approach Mutations

8.5.1 The approachCreate Mutation

8.5.2 The approachVote mutation

8.6 Summary

Part 3: Using GraphQL APIs

9 Using GraphQL APIs without a client library

9.1 Using a Web UI library

9.2 Running the web server

9.3 Making AJAX requests

9.4 Performing GraphQL query requests

9.4.1 Using GraphQL fragments in UI components

9.4.2 Including variables in requests

9.5 Performing GraphQL mutation requests

9.5.1 The login/signup forms

9.5.2 Handling generic server errors

9.5.3 Authenticating GraphQL requests

9.5.4 The create-need form

9.5.5 The create-approach form

9.5.6 Voting on an Approach

9.6 Performing query requests scoped for a user

9.6.1 The MyNeeds page

9.6.2 The search form

9.7 Wrap-up

9.8 Summary

10 Using GraphQL APIs with the Apollo client

What's inside

  • Define a GraphQL schema for relational and document databases
  • Query services and other APIs efficiently
  • Optimize GraphQL resolvers with data caching and batching
  • Cache a data graph for clients
  • Design GraphQL fragments that match UI components' data requirements

About the reader

For web developers familiar with building client-server applications.

About the author

Samer Buna has over 20 years of experience in software development including front-ends, back-ends, mobile apps, API design, databases, and scalability. He operates

placing your order...

Don't refresh or navigate away from the page.
Manning Early Access Program (MEAP) Read chapters as they are written, get the finished eBook as soon as it’s ready, and receive the pBook long before it's in bookstores.
print book $32.49 $49.99 pBook + eBook + liveBook
Additional shipping charges may apply
GraphQL in Action (print book) added to cart
continue shopping
go to cart

eBook $25.99 $39.99 3 formats + liveBook
GraphQL in Action (eBook) added to cart
continue shopping
go to cart

Prices displayed in rupees will be charged in USD when you check out.

FREE domestic shipping on three or more pBooks