Learning GraphQL
Declarative Data Fetching for Modern Web Apps
Eve Porcello and Alex Banks
Learning GraphQL
by Eve Porcello and Alex Banks
Copyright © 2018 Eve Porcello and Alex Banks. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North,
Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional
use. Online editions are also available for most titles (http://oreilly.com/safari).
For more information, contact our corporate/institutional sales department: 800-
998-9938 or corporate@oreilly.com.
Acquisitions Editor: Mary Treseler
Development Editor: Alicia Young
Production Editor: Justin Billing
Copyeditor: Chris Edwards
Proofreader: Octal Publishing, Inc.
Indexer: WordCo, Inc.
Interior Designer: David Futato
Cover Designer: Karen Montgomery
Illustrator: Melanie Yarbrough
August 2018: First Edition
Revision History for the First Edition
2018-08-08: First Release
See http://oreilly.com/catalog/errata.csp?isbn=9781492030713 for release
details.
The O’Reilly logo is a registered trademark of O’Reilly Media, Inc. Learning
GraphQL, the cover image, and related trade dress are trademarks of O’Reilly
Media, Inc.
The views expressed in this work are those of the authors, and do not represent
the publisher’s views. While the publisher and the authors have used good faith
efforts to ensure that the information and instructions contained in this work are
accurate, the publisher and the authors disclaim all responsibility for errors or
omissions, including without limitation responsibility for damages resulting
from the use of or reliance on this work. Use of the information and instructions
contained in this work is at your own risk. If any code samples or other
technology this work contains or describes is subject to open source licenses or
the intellectual property rights of others, it is your responsibility to ensure that
your use thereof complies with such licenses and/or rights.
978-1-492-03071-3
[LSI]
Preface
Acknowledgments
This book would not be a book without the help of many phenomenal people. It
started with the idea from Ally MacDonald, our editor for Learning React, who
encouraged us to write Learning GraphQL. We were then very lucky to get to
work with Alicia Young, who shepherded the book to its printing. Thanks to
Justin Billing, Melanie Yarbrough, and Chris Edwards who sanded off all of the
rough edges during an extremely thorough production edit.
Throughout the process, we were fortunate to get feedback from Peggy Rayzis
and Sashko Stubailo from the Apollo team who shared their insights and hot tips
about the latest features. Thanks also to Adam Rackis, Garrett McCullough, and
Shivi Singh, who were excellent technical editors.
We wrote this book about GraphQL because we love GraphQL. We think you
will too.
Conventions Used in This Book
The following typographical conventions are used in this book:
Italic
Indicates new terms, URLs, email addresses, filenames, and file extensions.
Constant width
Used for program listings, as well as within paragraphs to refer to program
elements such as variable or function names, databases, data types,
environment variables, statements, and keywords.
Constant width bold
Shows commands or other text that should be typed literally by the user.
Constant width italic
Shows text that should be replaced with user-supplied values or by values
determined by context.
This element signifies a tip or suggestion.
TIP
NOTE
This element signifies a general note.
This element indicates a warning or caution.
WARNING
Using Code Examples
Supplemental material (code examples, exercises, etc.) is available for download
at https://github.com/moonhighway/learning-graphql/.
This book is here to help you get your job done. In general, if example code is
offered with this book, you may use it in your programs and documentation. You
do not need to contact us for permission unless you’re reproducing a significant
portion of the code. For example, writing a program that uses several chunks of
code from this book does not require permission. Selling or distributing a CD-
ROM of examples from O’Reilly books does require permission. Answering a
question by citing this book and quoting example code does not require
permission. Incorporating a significant amount of example code from this book
into your product’s documentation does require permission.
We appreciate, but do not require, attribution. An attribution usually includes the
title, author, publisher, and ISBN. For example: “Learning GraphQL by Eve
Porcello and Alex Banks (O’Reilly). Copyright 2018 Eve Porcello and Alex
Banks, 978-1-492-03071-3.”
If you feel your use of code examples falls outside fair use or the permission
given above, feel free to contact us at permissions@oreilly.com.