Flexible, Robust Services for Queries, Mutations, and Subscriptions
Bruce Williams / Ben Wilson
简介
GraphQL is a new way of structuring and building web services, and the result is transformational. Find out how to offer a more tailored, cohesive experience to your users, easily aggregate data from different data sources, and improve your back end’s maintainability with Absinthe’s declarative approach to defining how your API works.
Build a GraphQL-based API from scratch using Absinthe, starting from core principles. Learn the type system and how to expand your schema to suit your application’s needs. Discover a growing ecosystem of tools and utilities to understand, debug, and document your API. Take it to production, but do it safely with solid best practices in mind. Find out how complexity analysis and persisted queries can let you support your users flexibly, but responsibly too. Along the way, discover how Elixir makes all the difference for a high performance, fault-tolerant API. Use asynchronous and batching execution, or write your own custom add-ons to extend Absinthe. Go live with subscriptions, delivering data over websockets on top of Elixir (and Erlang/OTP’s) famous solid performance and real-time capabilities.
Transform your applications with the powerful combination of Elixir and GraphQL, using Absinthe.
目录
Introduction
Build a GraphQL API
Meet GraphQL
On the Client
On the Server
Absinthe and the Tech Stack
Moving On
Building a Schema
Preparing the Application
Our Schema Module
Making a Query excerpt
Running Our Query with GraphiQL
Testing Our Query
Moving On
Taking User Input excerpt
Defining Field Arguments
Providing Field Argument Values
Using Enumeration Types
Modeling Input Objects
Marking Arguments as Non-Null
Creating Your Own Scalar Types
Moving On
Adding Flexibility
Organizing a Schema
Understanding Abstract Types
Using Named Fragments
Moving On
Making a Change with Mutations
Defining a Root Mutation Type
Building the Resolver
Handling Mutation Errors
Moving On
Going Live with Subscriptions
Setting Up Subscriptions
Event Modeling
Submitting Subscriptions excerpt
Testing Subscriptions
Subscription Triggers
Moving On
Publish Your API
Resolution Middleware
Our First Module
Applying Middleware
Setting Defaults
Moving On
Securing with Authentication and Authorization
Logging In
Using the Execution Context
Securing Fields
Structuring for Authorization
Moving On
Tuning Resolution
Understanding the Problem
Using Built-in Plugins
Discovering Dataloader
Moving On
Use Your API
Driving Phoenix Actions with GraphQL
Building an Action
Handling Input
Complex Queries
Moving On
Integrating with the Frontend
Starting Simple
Choosing a Framework
Using Apollo Client
Using Relay
Wrapping Up