GraphQL in Action
GraphQL in Action gives you the tools to get comfortable with the GraphQL language, build and optimize a data API service, and use it in a front-end client application.

Summary
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.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
GraphQL APIs are fast, efficient, and easy to maintain. They reduce app latency and server cost while boosting developer productivity. This powerful query layer offers precise control over API requests and returns, making apps faster and less prone to error.

About the book
GraphQL in Action gives you the tools to get comfortable with the GraphQL language, build and optimize a data API service, and use it in a front-end client application. By working through set up, security, and error handling you'll learn to create a complete GraphQL server. You'll also unlock easy ways to incorporate GraphQL into your existing codebase so you can build simple, scalable data APIs.

What's inside

Define a GraphQL schema for relational and document databases
Implement GraphQL types using both the schema language and object constructor methods
Optimize GraphQL resolvers with data caching and batching
Design GraphQL fragments that match UI components' data requirements
Consume GraphQL API queries, mutations, and subscriptions with and without a GraphQL client library

About the reader
For web developers familiar with client-server applications.

About the author
Samer Buna has over 20 years of experience in software development including front-ends, back-ends, API design, and scalability.

Table of Contents

PART 1- EXPLORING GRAPHQL

1 Introduction to GraphQL

2 Exploring GraphQL APIs

3 Customizing and organizing GraphQL operations

PART 2 - BUILDING GRAPHQL APIs

4 Designing a GraphQL schema

5 Implementing schema resolvers

6 Working with database models and relations

7 Optimizing data fetching

8 Implementing mutations

PART 3 - USING GRAPHQL APIs

9 Using GraphQL APIs without a client library

10 Using GraphQL APIs with Apollo client
1137213659
GraphQL in Action
GraphQL in Action gives you the tools to get comfortable with the GraphQL language, build and optimize a data API service, and use it in a front-end client application.

Summary
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.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
GraphQL APIs are fast, efficient, and easy to maintain. They reduce app latency and server cost while boosting developer productivity. This powerful query layer offers precise control over API requests and returns, making apps faster and less prone to error.

About the book
GraphQL in Action gives you the tools to get comfortable with the GraphQL language, build and optimize a data API service, and use it in a front-end client application. By working through set up, security, and error handling you'll learn to create a complete GraphQL server. You'll also unlock easy ways to incorporate GraphQL into your existing codebase so you can build simple, scalable data APIs.

What's inside

Define a GraphQL schema for relational and document databases
Implement GraphQL types using both the schema language and object constructor methods
Optimize GraphQL resolvers with data caching and batching
Design GraphQL fragments that match UI components' data requirements
Consume GraphQL API queries, mutations, and subscriptions with and without a GraphQL client library

About the reader
For web developers familiar with client-server applications.

About the author
Samer Buna has over 20 years of experience in software development including front-ends, back-ends, API design, and scalability.

Table of Contents

PART 1- EXPLORING GRAPHQL

1 Introduction to GraphQL

2 Exploring GraphQL APIs

3 Customizing and organizing GraphQL operations

PART 2 - BUILDING GRAPHQL APIs

4 Designing a GraphQL schema

5 Implementing schema resolvers

6 Working with database models and relations

7 Optimizing data fetching

8 Implementing mutations

PART 3 - USING GRAPHQL APIs

9 Using GraphQL APIs without a client library

10 Using GraphQL APIs with Apollo client
49.99 In Stock
GraphQL in Action

GraphQL in Action

by Samer Buna
GraphQL in Action

GraphQL in Action

by Samer Buna

Paperback

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

Related collections and offers


Overview

GraphQL in Action gives you the tools to get comfortable with the GraphQL language, build and optimize a data API service, and use it in a front-end client application.

Summary
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.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the technology
GraphQL APIs are fast, efficient, and easy to maintain. They reduce app latency and server cost while boosting developer productivity. This powerful query layer offers precise control over API requests and returns, making apps faster and less prone to error.

About the book
GraphQL in Action gives you the tools to get comfortable with the GraphQL language, build and optimize a data API service, and use it in a front-end client application. By working through set up, security, and error handling you'll learn to create a complete GraphQL server. You'll also unlock easy ways to incorporate GraphQL into your existing codebase so you can build simple, scalable data APIs.

What's inside

Define a GraphQL schema for relational and document databases
Implement GraphQL types using both the schema language and object constructor methods
Optimize GraphQL resolvers with data caching and batching
Design GraphQL fragments that match UI components' data requirements
Consume GraphQL API queries, mutations, and subscriptions with and without a GraphQL client library

About the reader
For web developers familiar with client-server applications.

About the author
Samer Buna has over 20 years of experience in software development including front-ends, back-ends, API design, and scalability.

Table of Contents

PART 1- EXPLORING GRAPHQL

1 Introduction to GraphQL

2 Exploring GraphQL APIs

3 Customizing and organizing GraphQL operations

PART 2 - BUILDING GRAPHQL APIs

4 Designing a GraphQL schema

5 Implementing schema resolvers

6 Working with database models and relations

7 Optimizing data fetching

8 Implementing mutations

PART 3 - USING GRAPHQL APIs

9 Using GraphQL APIs without a client library

10 Using GraphQL APIs with Apollo client

Product Details

ISBN-13: 9781617295683
Publisher: Manning
Publication date: 03/09/2021
Pages: 384
Product dimensions: 7.38(w) x 9.25(h) x 0.80(d)

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 jsComplete.com.

Table of Contents

Preface xv

Acknowledgments xvii

About this book xix

About the author xxii

About the cover illustration xxiii

Part 1 Exploring GraphQL 1

1 Introduction to GraphQL 3

1.1 What is GraphQL? 4

The big picture 5

GraphQL is a specification 9

GraphQL is a language 9

GraphQL is a service 11

1.2 Why GraphQL? 14

What about REST APIs? 17

The GraphQL way 18

REST APIs and GraphQL APIs in action 20

1.3 GraphQL problems 25

Security 25

Caching and optimizing 26

Learning curve 28

2 Exploring GraphQL APIs 30

2.1 The GraphiQL editor 31

2.2 The basics of the GraphQL language 36

Requests 36

Fields 39

2.3 Examples from the GitHub API 41

Reading data from GitHub 41

Updating data at GitHub 43

Introspective queries 44

Customizing and organizing GraphQL operations 47

3.1 Customizing fields with arguments 48

Identifying a single record to return 48

Limiting the number of records returned by a list field 49

Ordering records returned by a list field 51

Paginating through a list of records 51

Searching and filtering 53

Providing input for mutations 54

3.2 Renaming fields with aliases 55

3.3 Customizing responses with directives 57

Variables and input values 58

The @include directive 61

The @skip directive 62

The @deprecated directive 63

3.4 GraphQL fragments 63

Why fragments? 63

Defining and using fragments 64

Fragments and DRY 65

Fragments and UI components 66

Inline fragments for interfaces and unions 71

Part 2 Building GraphQL APIs 75

4 Designing a GraphQL schema 77

4.1 Why AZdev? 77

4.2 The API requirements for AZdev 78

The core types 80

4.3 Queries 82

Listing the latest Task records 82

Search and the union/interface types 84

Using an interface type 87

The page for one Task record 88

Entity relationships 90

The ENUM type 91

List of scalar values 92

The page for a user's Task records 92

Authentication and authorization 93

4.4 Mutations 94

Mutation input 96

Deleting a user record 98

Creating a Task object 99

Creating and voting on Approach entries 100

4.5 Subscriptions 102

4.6 Full schema text 103

4.7 Designing database models 103

The User model 104

The Task/Approach models 105

The Approach Details model 107

Implementing schema resolvers 110

5.1 Running the development environment 110

Node.js packages 113

Environment variables 113

5.2 Setting up the GraphQL runtime 113

Creating the schema object 115

Creating resolver functions 116

Executing requests 117

5.3 Communicating over HTTP 119

5.4 Building a schema using constructor objects 122

The Query type 123

Field arguments 125

Custom object types 127

Custom errors 129

5.5 Generating SDL text from object-based schemas 132

The schema language versus the object-based method 134

5.6 Working with asynchronous functions 135

Working with database models and relations 138

6.1 Running and connecting to databases 139

6.2 The taskMainList query 141

Defining object types 142

The context object 143

Transforming field names 147

Transforming field values 150

Separating interactions with PostgreSQL 152

6.3 Error reporting 154

6.4 Resolving relations 156

Resolving a one-to-one relation 157

Resolving a one-to-many relation 166

Optimizing data fetching 171

7.1 Caching and batching 172

The batch-loading function 175

Defining and using a Data-Loader instance 177

The loader for the approachList field 179

7.2 Single resource fields 182

7.3 Circular dependencies in GraphQL types 187

Deeply nested field attacks 188

7.4 Using DataLoader with custom IDs for caching 190

The taskMainList field 190

The search field 193

7.5 Using DataLoader with MongoDB 199

8 Implementing mutations 208

8.1 The mutators context object 209

8.2 The Mutation type 211

8.3 User mutations 211

The userCreate mutation 211

The userLogin mutation 217

8.4 Authenticating API consumers 221

The me root query field 226

8.5 Mutations for the Task model 232

8.6 Mutations for the Approach model 235

The approachCreate mutation 236

The approachVote mutation 244

8.7 The userDelete mutation 246

Part 3 Using GraphQL APIs 251

9 Using GraphQL APIs without a client library 253

9.1 Using a web UI library 254

9.2 Running the web server 255

9.3 Making Ajax requests 258

9.4 Performing GraphQL query requests 260

Using GraphQL fragments in UI components 263

Including variables in requests 265

9.5 Performing GraphQL mutation requests 269

The login/signup forms 269

Handling generic server errors 273

Authenticating GraphQL requests 277

The Create Task form 278

The Create Approach form 281

Voting on an Approach 286

9.6 Performing query requests scoped for a user 287

The Search form 289

9.7 Next up 291

10 Using GraphQL APIs with Apollo client 293

10.1 Using Apollo Client with JavaScript 294

Making a query request 295

Making a mutation request 300

10.2 Using Apollo Client with React 303

Using the query and mutate methods directly 303

Including authentication headers 306

Using Apollo hook functions 309

Using the automatic cache 316

Manually updating the cache 317

Performing operations conditionally 321

10.3 Managing local app state 326

10.4 Implementing and using GraphQL subscriptions 332

Polling and refetching 332

Implementing subscriptions 334

Apollo Server 340

Using subscriptions in UJs 342

Wrapping up 345

Index 347

From the B&N Reads Blog

Customer Reviews