Cover
Copyright
Table of Contents
Preface
How the Book Is Structured
About the Updates
What's New in Version 0.3?
Warescription
Book Bug Bounty
Source Code and Its License
Creative Commons and the Four-to-Free (42F) Guarantee
Acknowledgments
GraphQL in Five Minutes
Step #1: Gotta Get a GraphiQL
Step #2: Drafting a Document
Step #3: Making the Request
Step #4: Looking at the Docs
The Role of GraphQL
So, What Did We Just Do?
What Exactly is GraphQL?
A Specification
A Set of Conventions
A Lot of Froth
GraphQL Design Principles
Hierarchical
Client-Focused
Strongly Typed
Introspective
Key GraphQL Features
Platform Neutral
Protocol Neutral
Storage Neutral
Bandwidth-Friendly
GraphQL Compared To…
…REST Web Services
…RPC Web Services
…SQL Databases
…Document and NoSQL Databases
Top-Level GraphQL Terms
Document
Operation
Operation Name
Arguments and Variables
Mutations and Objects
Errors
GraphQL Test Environments
The Test Server
Our Local Server: Express
Where to Run the Server
Installing the Server
Install Node.js
Obtain the Server Scripts
Install Dependencies
Running the Server
Testing with GraphiQL
Trying a Mutation
GitHub
Getting an Authentication Token
Accessing GitHub's GraphiQL
GitHub API Documentation and Support
And Now, Onwards and Upwards!
Basic Dynamic GraphQL in Android
Dynamic vs. Static
Dynamic
Static
GraphQL and HTTP
Using OkHttp for GraphQL
The Activity
The UI
The Dependencies
The Query
The Observable Chain
The Subscription
The Results
Getting a Parsed Response
The Response Objects and Revised Query
The Revised Rx and UI
The Revised Results
Can't We Do Better Than Maps of Objects?
Basic Static GraphQL in Android
Android Apps and Code Generation
R and BuildConfig
AIDL
Data Binding
Compiled SQL Queries
The Staticizer
Introducing Apollo and Apollo-Android
Using Apollo-Android
Installing Node
Installing apollo-codegen
Setting the Gradle Version
Adding the Plugin
Downloading the Schema
Writing the GraphQL
What You Get
Using the Generated APIs
Creating an ApolloClient
Making the Observable
Working with the Results
Names and Apollo-Android
Was All of This Worth It?
Objects, Fields, and Types
Introducing the GraphQL Schema Definition Language
Objects
Fields
Root Fields
Selection Set
Data Types in GraphQL
Numbers
Strings and IDs
Custom Scalars
Enums
Objects
Interfaces and Unions
Type Modifiers
Lists
Non-Null
Combo Platters
Trip, In Schema Definition Language
Fragments
The Role of Fragments
Creating a Fragment
Using a Fragment
Fragments, And Your Output
Fragments and Your Android Code
Where Apollo-Android Generated Code Gets Generated
Arguments and Variables
Arguments
Argument Data Types and Input Objects
Argument Patterns
Searching and Sorting
CRUD
Paging
Using Arguments in Android
Variables
Declaring the Variables
Applying the Variables
Supplying Values for the Variables
Variables in Android
Dynamic GraphQL
Static GraphQL
…And Never the Twain Shall Meet
Switching to a Fragment
Updating the Observable
Handling the Searches
A Little Bit of CRUD
Running the Test Server
The Project and Your Test Server
A Small Schema Reminder
Our New GraphQL Document
What Apollo-Android Generates
Adding a Data Entry Fragment
Invoking a Mutation
The Results
Aliases
Applying Aliases
One, Two, Many, Lots
Multiple Root Fields
Making the Same Query Over and Over and Over
Mutating N Items
Aliases with Apollo-Android
GraphQL Execution Rules
Interfaces, Unions, and Inline Fragments
Interfaces
Fields In Common
Distinct Fields
Unions
Interfaces, Unions, and Apollo-Android
Miscellaneous GraphQL Syntax
Arguments on Nested Fields
Scenario: Conversion
Scenario: Filtering
Developing Clients Using Arguments on Nested Fields
Directives
@include and @skip
Custom Directives
Deprecations
Introspection
Adding a Type To Your Response
Introspection Beyond the Type Name
Requesting the Roots
Listing the Types
Collecting the Fields
Field Types
Field Arguments
Field Deprecation Status
Type-Specific Results
Authentication and the Viewer Pattern
Convention Over Specification
What You Get Stems From Who You Are
Exploring GitHub's Approach
Using Their GraphiQL
Using the Token
Tokens and Android
Getting the Schema
Adding the Token to the Project
Adding the Token
Making the Request
Queries and Paging
Taking a Page from GitHub
Starring Some Repositories
Getting a Page of Results
Examining the Query and Its Results
The Viewer
The starredRepositories
The Edges
The Page Info
Please, GitHub, Can I Have Some More?
Paging with Apollo-Android
Defining the GraphQL
RxJava Recipe
The Rest of the RecyclerView
Securing GraphQL
Securing the Network
SSL Basics
OkHttp Certificate Pinning
Establishing a Pin
Implementing a Pin Set
Pinning Against a Root CA
OkHttp Cleartext Ban
Network Security Configuration
CWAC-NetSecurity
NetCipher
Testing GraphQL
Testing Using a Real Server
Mocking the Apollo-Android Response
Mocking the OkHttp Response
Mocking the Server Response
Advanced Apollo-Android
Support for Scalar Types
Gradle Configuration
Implementing Adapters
Registering Adapters