Full Stack GraphQL Applications

Book description

Build hyper-fast and hyper-efficient web applications with GraphQL! This practical, comprehensive guide introduces the powerful GRANDStack for developing full stack web applications based in graph data structures.

In Full Stack GraphQL Applications you will learn how to:

  • Build backend functionalities for GraphQL applications
  • Model a GraphQL API with GraphQL type definitions
  • Utilize Neo4j as a backend database
  • Handle authentication and authorization with GraphQL
  • Implement pagination and rate limiting in a GraphQL API
  • Develop a GraphQL service with Apollo Server
  • Install Neo4j Database on different platforms
  • Create a basic frontend application using React and Apollo Client
  • Deploy a full stack GraphQL application to the cloud

The GraphQL query language radically reduces over-fetching or under-fetching of data by constructing precise graph-based data requests. In Full Stack GraphQL Applications you’ll learn how to build graph-aware web applications that take full advantage of GraphQL’s amazing efficiency. Neo4j’s William Lyon teaches you everything you need to know to design, deploy, and maintain a GraphQL API from scratch. He reveals how you can build your web apps with GraphQL, React, Apollo, and Neo4j Database, aka “the GRANDstack,” to get maximum performance out of GraphQL.

About the Technology
The GraphQL API query language radically streamlines data exchanges with backend servers by representing application data as easy-to-understand graphs. You can amplify GraphQL’s benefits by using graph-aware tools and data stores, like React, Apollo, and Neo4j, throughout your application. A full stack graph approach provides a consistent data model end to end, reducing friction in data fetching and increasing developer productivity.

About the Book
Full Stack GraphQL Applications teaches you to build graph-aware web applications using GraphQL, React, Apollo, and the Neo4j database, collectively called “the GRANDstack.” Practical, hands-on examples quickly develop your understanding of how the GRANDstack fits together. As you go, you’ll create and deploy to the cloud a full-featured web application that includes search, authentication, and more. Soon, you’ll be ready to deploy end-to-end applications that take full advantage of GraphQL’s outstanding performance.

What's Inside
  • Building a GraphQL backend using Neo4j
  • Authentication and authorization with GraphQL
  • Pagination and GraphQL abstract types
  • A basic frontend application using React and Apollo Client
  • Deploying to the cloud with Netlify, AWS Lambda, Auth0, and Neo4j Aura


About the Reader
For full stack web developers. No experience with GraphQL or graph databases required.

About the Author
William Lyon is a Staff Developer Advocate at Neo4j and blogger at lyonwj.com.

Quotes
For anyone who wants to make amazing full stack apps with GraphQL.
- Gustavo Gomes, Troido

This book exceeded my expectations. It is easy to follow, and has everything you need to create a complex and modern full stack application.
- Danilo Zeković, NeonCat.io

A polished and thoughtful guide to building modern GraphQL applications.
- Jose San Leandro, ioBuilders

An excellent resource on developing GraphQL applications using cutting-edge technologies like Neo4j and React.
- Theofanis Despoudis, WP Engine

Table of contents

  1. inside front cover
  2. Full Stack GraphQL Applications
  3. Copyright
  4. contents
  5. front matter
    1. preface
    2. acknowledgments
    3. about this book
      1. Who should read this book?
      2. How this book is organized: A roadmap
      3. About the code
      4. Software/hardware requirements
      5. liveBook discussion forum
      6. Other online resources
    4. about the author
    5. about the cover illustration
  6. Part 1 Getting started with full stack GraphQL
  7. 1 What is full stack GraphQL?
    1. 1.1 A look at full stack GraphQL
    2. 1.2 GraphQL
      1. 1.2.1 GraphQL type definitions
      2. 1.2.2 Querying with GraphQL
      3. 1.2.3 Advantages of GraphQL
      4. 1.2.4 Disadvantages of GraphQL
      5. 1.2.5 GraphQL tooling
    3. 1.3 React
      1. 1.3.1 React components
      2. 1.3.2 JSX
      3. 1.3.3 React tooling
    4. 1.4 Apollo
      1. 1.4.1 Apollo Server
      2. 1.4.2 Apollo Client
    5. 1.5 Neo4j Database
      1. 1.5.1 Property graph data model
      2. 1.5.2 Cypher query language
      3. 1.5.3 Neo4j tooling
    6. 1.6 How it all fits together
      1. 1.6.1 React and Apollo Client: Making the request
      2. 1.6.2 Apollo Server and GraphQL backend
      3. 1.6.3 React and Apollo Client: Handling the response
    7. 1.7 What we will build in this book
    8. 1.8 Exercises
    9. Summary
  8. 2 Graph thinking with GraphQL
    1. 2.1 Your application data is a graph
    2. 2.2 Graphs in GraphQL
      1. 2.2.1 API modeling with type definitions: GraphQL-first development
      2. 2.2.2 Resolving data with resolvers
      3. 2.2.3 Our first resolver
    3. 2.3 Combining type definitions and resolvers with Apollo Server
      1. 2.3.1 Using Apollo Server
      2. 2.3.2 Apollo Studio
      3. 2.3.3 Implementing resolvers
      4. 2.3.4 Querying using Apollo Studio
    4. 2.4 Exercises
    5. Summary
  9. 3 Graphs in the database
    1. 3.1 Neo4j overview
    2. 3.2 Graph data modeling with Neo4j
      1. 3.2.1 The property graph model
      2. 3.2.2 Database constraints and indexes
    3. 3.3 Data modeling considerations
      1. 3.3.1 Node vs. property
      2. 3.3.2 Node vs. relationship
      3. 3.3.3 Indexes
      4. 3.3.4 Specificity of relationship types
      5. 3.3.5 Choosing a relationship direction
    4. 3.4 Tooling: Neo4j desktop
    5. 3.5 Tooling: Neo4j Browser
    6. 3.6 Cypher
      1. 3.6.1 Pattern matching
      2. 3.6.2 Properties
      3. 3.6.3 CREATE
      4. 3.6.4 MERGE
      5. 3.6.5 Defining database constraints with cypher
      6. 3.6.6 MATCH
      7. 3.6.7 Aggregations
    7. 3.7 Using the Neo4j client drivers
    8. 3.8 Exercises
    9. Summary
  10. 4 The Neo4j GraphQL Library
    1. 4.1 Common GraphQL problems
      1. 4.1.1 Poor performance and the n + 1 query problem
      2. 4.1.2 Boilerplate and developer productivity
    2. 4.2 Introducing GraphQL database integrations
    3. 4.3 The Neo4j GraphQL Library
      1. 4.3.1 Project setup
      2. 4.3.2 Generated GraphQL schema from type definitions
    4. 4.4 Basic GraphQL queries
    5. 4.5 Ordering and pagination
    6. 4.6 Nested queries
    7. 4.7 Filtering
      1. 4.7.1 where argument
      2. 4.7.2 Nested filter
      3. 4.7.3 Logical operators: AND, OR
      4. 4.7.4 Filtering in selections
    8. 4.8 Working with temporal fields
      1. 4.8.1 Using a Date type in queries
      2. 4.8.2 Date and DateTime filters
    9. 4.9 Working with spatial data
      1. 4.9.1 The Point type in selections
      2. 4.9.2 Distance filter
    10. 4.10 Adding custom logic to our GraphQL API
      1. 4.10.1 The @cypher GraphQL schema directive
      2. 4.10.2 Implementing custom resolvers
    11. 4.11 Introspecting GraphQL schema from an existing database
    12. 4.12 Exercises
    13. Summary
  11. Part 2 Building the frontend
  12. 5 Building user interfaces with React
    1. 5.1 React overview
      1. 5.1.1 JSX and React elements
      2. 5.1.2 React components
      3. 5.1.3 Component hierarchy
    2. 5.2 Create React App
      1. 5.2.1 Creating a React application with Create React App
    3. 5.3 State and React Hooks
    4. 5.4 Exercises
    5. Summary
  13. 6 Client-side GraphQL with React and Apollo Client
    1. 6.1 Apollo Client
      1. 6.1.1 Adding Apollo Client to our React Application
      2. 6.1.2 Apollo Client hooks
      3. 6.1.3 GraphQL variables
      4. 6.1.4 GraphQL fragments
      5. 6.1.5 Caching with Apollo Client
    2. 6.2 GraphQL mutations
      1. 6.2.1 Creating nodes
      2. 6.2.2 Creating relationships
      3. 6.2.3 Updating and deleting
    3. 6.3 Client state management with GraphQL
      1. 6.3.1 Local-only fields and reactive variables
    4. 6.4 Exercises
    5. Summary
  14. Part 3 Full stack considerations
  15. 7 Adding authorization and authentication
    1. 7.1 Authorization in GraphQL: A naive approach
    2. 7.2 JSON Web Tokens
    3. 7.3 The @auth GraphQL schema directive
      1. 7.3.1 Rules and operations
      2. 7.3.2 The isAuthenticated authorization rule
      3. 7.3.3 The roles authorization rule
      4. 7.3.4 The allow authorization rule
      5. 7.3.5 The where authorization rule
      6. 7.3.6 The bind authorization rule
    4. 7.4 Auth0: JWT as a service
      1. 7.4.1 Configuring Auth0
      2. 7.4.2 Auth0 React
    5. 7.5 Exercises
    6. Summary
  16. 8 Deploying our full stack GraphQL application
    1. 8.1 Deploying our full stack GraphQL application
      1. 8.1.1 Advantages of this deployment approach
      2. 8.1.2 Disadvantages of our deployment approach
      3. 8.1.3 Overview of our approach to full stack GraphQL
    2. 8.2 Neo4j Aura database as a service
      1. 8.2.1 Creating a Neo4j Aura cluster
      2. 8.2.2 Connecting to a Neo4j Aura cluster
      3. 8.2.3 Uploading data to Neo4j Aura
      4. 8.2.4 Exploring the graph with Neo4j Bloom
    3. 8.3 Deploying a React application with Netlify Build
      1. 8.3.1 Adding a site to Netlify
      2. 8.3.2 Setting environment variables for Netlify builds
      3. 8.3.3 Netlify deploy previews
    4. 8.4 Serverless GraphQL with AWS Lambda and Netlify Functions
      1. 8.4.1 Serving a GraphQL API as a Lambda function
      2. 8.4.2 The Netlify dev CLI
      3. 8.4.3 Converting our GraphQL API to a Netlify function
      4. 8.4.4 Adding a custom domain in Netlify
    5. 8.5 Our deployment approach
    6. 8.6 Exercises
    7. Summary
  17. 9 Advanced GraphQL considerations
    1. 9.1 GraphQL abstract types
      1. 9.1.1 Interface types
      2. 9.1.2 Union types
      3. 9.1.3 Using abstract types with the Neo4j GraphQL library
    2. 9.2 Pagination with GraphQL
      1. 9.2.1 Offset pagination
      2. 9.2.2 Cursor pagination
    3. 9.3 Relationship properties
      1. 9.3.1 Interfaces and the @relationship GraphQL schema directive
      2. 9.3.2 Creating relationship properties
    4. 9.4 Wrapping up Full Stack GraphQL
    5. 9.5 Exercises
    6. Summary
  18. index
  19. inside back cover

Product information

  • Title: Full Stack GraphQL Applications
  • Author(s): William Lyon
  • Release date: August 2022
  • Publisher(s): Manning Publications
  • ISBN: 9781617297038