Full Stack Development with Angular and GraphQL: Learn to build scalable monorepo and a complete Angular app using Apollo, Lerna, and GraphQL
- Length: 390 pages
- Edition: 1
- Language: English
- Publisher: Packt Publishing
- Publication Date: 2022-03-30
- ISBN-10: 1800202466
- ISBN-13: 9781800202467
- Sales Rank: #5984011 (See Top 100 Books)
Use tools such as Lerna and GraphQL Code Generator to leverage recent features like NPM Workspaces for configuring a mono-repo project and Apollo Client’s reactive variables to easily manage the local state of your app
Key Features
- Use Angular modules and components to build apps that you can easily scale and maintain in the future
- Develop a GraphQL API for a small social network app using Node.js, Express, and Apollo Server
- Use Apollo Client to integrate Angular with a GraphQL server and manage your application’s local state
Book Description
Angular is one of the most popular JavaScript frameworks in modern web app development allowing developers to not only build apps and reuse the code but also develop apps for any deployment target. For web, mobile web, native mobile, and native desktop, GraphQL is the modern and REST alternative for querying web APIs. Using Angular, TypeScript and GraphQL will give you a future-proof and scalable stack you can start building apps around.
This book shows you how to build apps using cutting-edge technologies. You’ll learn how to solve common web development problems with GraphQL and Apollo, such as database access, authentication, and image uploads.
The book starts by introducing you to building full stack apps with Angular and GraphQL. Next, you’ll learn how to create a monorepo project with Lerna and NPM Workspaces and configure a Node.js app to use GraphQL with Express and Apollo Server. You’ll also understand the basics of Angular architecture and routing. Later, the book demonstrates how to build a professionally-looking UI with Angular Material, use Apollo Client to interface with the server to get data from the built GraphQL API.
You’ll learn about Apollo Client’s type and field policies, and various fetching policies. In addition to this, you’ll learn about local state management and reactive variables with Apollo Client and how to generate TypeScript types and even Angular Apollo services for your GraphQL schema and queries using GraphQL Code Generator to implement a scalable codebase.
By the end of this book, you’ll have the skills you need to be able to build your own full stack application.
What you will learn
- Create a monorepo project with Lerna and NPM workspaces
- Add realtime support with GraphQL subscriptions
- Build a frontend with a modular architecture and Material Design UI components to consume the GraphQL API
- Use GraphQL Code Generator to generate types and code for a type-safe and scalable code base
- Create Angular modules and smart and dumb components and share data between them
- Use Apollo Client features such as client-side queries and reactive variables for local state management
Who this book is for
This Angular GraphQL book is for Angular developers who want to learn how to use GraphQL and Apollo with Angular to build full-stack applications. This book does not assume prior knowledge of full-stack development with Angular and GraphQL.
Full Stack Development with Angular and GraphQL Contributors About the author About the reviewer Preface Who this book is for What this book covers To get the most out of this book Download the example code files Download the color images Conventions used Get in touch Share Your Thoughts Part 1: Setting Up the Development Environment, GraphQL Server, and Database Chapter 1: App Architecture and Development Environment Technical requirements The architecture and technologies Full-stack architecture The development technologies Running JavaScript on the server with Node.js Installing packages with npm Running a web server with Express.js GraphQL Integrating the frontend and backend with Apollo Saving data with TypeORM and MySQL Building the frontend with TypeScript and Angular Installing MySQL Configuring MySQL Server Testing MySQL Server Installing and configuring Node.js Installing Node.js with nvm Summary Chapter 2: Setting Up GraphQL with Node.js, Express.js, and Apollo Technical requirements Setting up a monorepo project Initializing our server project Generating a package.json file Installing Express.js and development dependencies Creating the server Watching and recompiling our code Creating a GraphQL API Installing the necessary libraries Exposing a simple GraphQL API Sending queries with Apollo Studio Creating a GraphQL schema for our social network Mocking our GraphQL API Linking the mocked data Configuring CORS Summary Chapter 3: Connecting the Database with TypeORM Technical requirements Creating a MySQL user and database Setting up TypeORM and MySQL Creating TypeORM entities Seeding test data Using Apollo with TypeORM Summary Chapter 4: Implementing Authentication and Image Uploads with Apollo Server Technical requirements What's JWT? Implementing authentication Protecting GraphQL queries and mutations Implementing image uploads Assignments Summary Chapter 5: Adding Realtime Support with Apollo Server Technical requirements Understanding GraphQL subscriptions Implementing GraphQL subscriptions Implementing JWT authentication with subscriptions Summary Part 2: Building the Angular Frontend with Realtime Support Chapter 6: Angular Application Architecture and Routing Technical requirements Installing the Angular CLI Angular CLI commands Initializing the Angular project Understanding the application architecture What's a module? What's a component? Understanding services and dependency injection Creating modules, services, and components Creating modules Creating components and services Understanding Angular routing How the Angular Router works The <base href> tag The routing modules The router outlet Importing the routing module Understanding and adding routes Route-matching strategies Route parameters Adding routes Adding navigation Debugging Angular applications Adding Angular Material Summary Chapter 7: Adding User Search Functionality Technical requirements Introducing and installing Apollo Client Importing Angular Material components Signing up and logging users in Defining GraphQL documents Defining types for user authentication Defining Apollo services Implementing the user authentication service Building and styling the signup UI Building and styling the login UI (assignment) Implementing the header component Implementing the footer and page not found components Implementing the user search dialog component Summary Chapter 8: Guarding Routes and Testing Authentication Technical requirements Guarding routes Sending the JWT Improving the search functionality (assignment) Using GraphQL fragments Local state management with Apollo Client Using the OnPush change detection strategy Testing the auth service and component(s) Testing the auth service Testing the auth guard Testing the header component Testing the search dialog component Testing other components Summary Chapter 9: Uploading Images and Adding Posts Technical requirements Image uploading with Angular and Apollo Setting up GraphQL Code Generator Adding fragments and mutations Generating types and services Implementing the post service Implementing the profile service Implementing the base component Implementing the profile component Defining field policies Creating the profile UI Styling the profile component Implementing the create post component Testing Summary Chapter 10: Fetching Posts and Adding Comments and Likes Technical requirements Improving the authentication system Adding queries and generating types and services Fetching paginated posts Implementing comments and likes services Implementing a presentational post component Displaying posts, comments, and likes Summary Part 3: Adding Realtime Support Chapter 11: Implementing GraphQL Subscriptions Technical requirements Persisting the component state with reactive variables Using field policies to rewrite dates Displaying comments Displaying new comments Updating the cache after removing comments Giving focus to the commenting box Setting up Apollo Client for subscriptions Implementing GraphQL subscriptions Summary Why subscribe? Other Books You May Enjoy Packt is searching for authors like you Share Your Thoughts
Donate to keep this site alive
How to download source code?
1. Go to: https://github.com/PacktPublishing
2. In the Find a repository… box, search the book title: Full Stack Development with Angular and GraphQL: Learn to build scalable monorepo and a complete Angular app using Apollo, Lerna, and GraphQL
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.