0%

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.

Table of Contents

  1. GraphQL in Action
  2. inside front cover
  3. Copyright
  4. dedication
  5. brief contents
  6. contents
  7. front matter
    1. preface
    2. acknowledgments
    3. about this book
    4. Who should read this book
    5. How this book is organized: a roadmap
    6. About the code
    7. Other online resources
    8. about the author
    9. about the cover illustration
  8. Part 1. Exploring GraphQL
  9. 1 Introduction to GraphQL
    1. 1.1 What is GraphQL?
    2. 1.1.1 The big picture
    3. 1.1.2 GraphQL is a specification
    4. 1.1.3 GraphQL is a language
    5. 1.1.4 GraphQL is a service
    6. 1.2 Why GraphQL?
    7. 1.2.1 What about REST APIs?
    8. 1.2.2 The GraphQL way
    9. 1.2.3 REST APIs and GraphQL APIs in action
    10. 1.3 GraphQL problems
    11. 1.3.1 Security
    12. 1.3.2 Caching and optimizing
    13. 1.3.3 Learning curve
    14. Summary
  10. 2 Exploring GraphQL APIs
    1. 2.1 The GraphiQL editor
    2. 2.2 The basics of the GraphQL language
    3. 2.2.1 Requests
    4. 2.2.2 Fields
    5. 2.3 Examples from the GitHub API
    6. 2.3.1 Reading data from GitHub
    7. 2.3.2 Updating data at GitHub
    8. 2.3.3 Introspective queries
    9. Summary
  11. 3 Customizing and organizing GraphQL operations
    1. 3.1 Customizing fields with arguments
    2. 3.1.1 Identifying a single record to return
    3. 3.1.2 Limiting the number of records returned by a list field
    4. 3.1.3 Ordering records returned by a list field
    5. 3.1.4 Paginating through a list of records
    6. 3.1.5 Searching and filtering
    7. 3.1.6 Providing input for mutations
    8. 3.2 Renaming fields with aliases
    9. 3.3 Customizing responses with directives
    10. 3.3.1 Variables and input values
    11. 3.3.2 The @include directive
    12. 3.3.3 The @skip directive
    13. 3.3.4 The @deprecated directive
    14. 3.4 GraphQL fragments
    15. 3.4.1 Why fragments?
    16. 3.4.2 Defining and using fragments
    17. 3.4.3 Fragments and DRY
    18. 3.4.4 Fragments and UI components
    19. 3.4.5 Inline fragments for interfaces and unions
    20. Summary
  12. Part 2. Building GraphQL APIs
  13. 4 Designing a GraphQL schema
    1. 4.1 Why AZdev?
    2. 4.2 The API requirements for AZdev
    3. 4.2.1 The core types
    4. 4.3 Queries
    5. 4.3.1 Listing the latest Task records
    6. 4.3.2 Search and the union/interface types
    7. 4.3.3 Using an interface type
    8. 4.3.4 The page for one Task record
    9. 4.3.5 Entity relationships
    10. 4.3.6 The ENUM type
    11. 4.3.7 List of scalar values
    12. 4.3.8 The page for a user’s Task records
    13. 4.3.9 Authentication and authorization
    14. 4.4 Mutations
    15. 4.4.1 Mutation input
    16. 4.4.2 Deleting a user record
    17. 4.4.3 Creating a Task object
    18. 4.4.4 Creating and voting on Approach entries
    19. 4.5 Subscriptions
    20. 4.6 Full schema text
    21. 4.7 Designing database models
    22. 4.7.1 The User model
    23. 4.7.2 The Task/Approach models
    24. 4.7.3 The Approach Details model
    25. Summary
  14. 5 Implementing schema resolvers
    1. 5.1 Running the development environment
    2. 5.1.1 Node.js packages
    3. 5.1.2 Environment variables
    4. 5.2 Setting up the GraphQL runtime
    5. 5.2.1 Creating the schema object
    6. 5.2.2 Creating resolver functions
    7. 5.2.3 Executing requests
    8. 5.3 Communicating over HTTP
    9. 5.4 Building a schema using constructor objects
    10. 5.4.1 The Query type
    11. 5.4.2 Field arguments
    12. 5.4.3 Custom object types
    13. 5.4.4 Custom errors
    14. 5.5 Generating SDL text from object-based schemas
    15. 5.5.1 The schema language versus the object-based method
    16. 5.6 Working with asynchronous functions
    17. Summary
  15. 6 Working with database models and relations
    1. 6.1 Running and connecting to databases
    2. 6.2 The taskMainList query
    3. 6.2.1 Defining object types
    4. 6.2.2 The context object
    5. 6.2.3 Transforming field names
    6. 6.2.4 Transforming field values
    7. 6.2.5 Separating interactions with PostgreSQL
    8. 6.3 Error reporting
    9. 6.4 Resolving relations
    10. 6.4.1 Resolving a one-to-one relation
    11. 6.4.2 Resolving a one-to-many relation
    12. Summary
  16. 7 Optimizing data fetching
    1. 7.1 Caching and batching
    2. 7.1.1 The batch-loading function
    3. 7.1.2 Defining and using a DataLoader instance
    4. 7.1.3 The loader for the approachList field
    5. 7.2 Single resource fields
    6. 7.3 Circular dependencies in GraphQL types
    7. 7.3.1 Deeply nested field attacks
    8. 7.4 Using DataLoader with custom IDs for caching
    9. 7.4.1 The taskMainList field
    10. 7.4.2 The search field
    11. 7.5 Using DataLoader with MongoDB
    12. Summary
  17. 8 Implementing mutations
    1. 8.1 The mutators context object
    2. 8.2 The Mutation type
    3. 8.3 User mutations
    4. 8.3.1 The userCreate mutation
    5. 8.3.2 The userLogin mutation
    6. 8.4 Authenticating API consumers
    7. 8.4.1 The me root query field
    8. 8.5 Mutations for the Task model
    9. 8.6 Mutations for the Approach model
    10. 8.6.1 The approachCreate mutation
    11. 8.6.2 The approachVote mutation
    12. 8.7 The userDelete mutation
    13. Summary
  18. Part 3. Using GraphQL APIs
  19. 9 Using GraphQL APIs without a client library
    1. 9.1 Using a web UI library
    2. 9.2 Running the web server
    3. 9.3 Making Ajax requests
    4. 9.4 Performing GraphQL query requests
    5. 9.4.1 Using GraphQL fragments in UI components
    6. 9.4.2 Including variables in requests
    7. 9.5 Performing GraphQL mutation requests
    8. 9.5.1 The login/signup forms
    9. 9.5.2 Handling generic server errors
    10. 9.5.3 Authenticating GraphQL requests
    11. 9.5.4 The Create Task form
    12. 9.5.5 The Create Approach form
    13. 9.5.6 Voting on an Approach
    14. 9.6 Performing query requests scoped for a user
    15. The Search form
    16. 9.7 Next up
    17. Summary
  20. 10 Using GraphQL APIs with Apollo client
    1. 10.1 Using Apollo Client with JavaScript
    2. 10.1.1 Making a query request
    3. 10.1.2 Making a mutation request
    4. 10.2 Using Apollo Client with React
    5. 10.2.1 Using the query and mutate methods directly
    6. 10.2.2 Including authentication headers
    7. 10.2.3 Using Apollo hook functions
    8. 10.2.4 Using the automatic cache
    9. 10.2.5 Manually updating the cache
    10. 10.2.6 Performing operations conditionally
    11. 10.3 Managing local app state
    12. 10.4 Implementing and using GraphQL subscriptions
    13. 10.4.1 Polling and refetching
    14. 10.4.2 Implementing subscriptions
    15. 10.4.3 Apollo Server
    16. 10.4.4 Using subscriptions in UIs
    17. Summary
    18. Wrapping up
  21. index
  22. inside back cover
52.14.253.170