
GraphQL is a query language that empowers clients to request exactly the fields they need, as shown by filtering citizenship and credit score while omitting unnecessary data, with REST comparisons.
Learn how GraphQL prevents over fetching by returning only requested fields like name and image, and avoid under fetching with precise queries.
GraphQL prevents under-fetching and over-fetching by querying a category and its products in one request, returning the category name and each product's image and name, avoiding multiple REST calls.
Explore how GraphQL organizes data through strict typing and graph-like relationships, linking categories to products in one-to-many patterns, and querying products to reveal images, names, and categories.
Set up your local environment for a GraphQL API with Node by installing Node, VS Code, and the GraphQL extension, and use the GitHub repo for all three projects.
Set up a GraphQL server using JavaScript and Apollo Server to serve product data for an e-commerce app, defining type definitions and resolvers for queries and data access.
Explore GraphQL scalar types—string, int, float, boolean—and how resolvers return single values, with non-null via bang to prevent null results, contrasting with object types.
Learn how to return arrays in GraphQL by defining an array of a type (string, int, float, boolean) and using non-null constraints with bang; decide between null or an array.
Enable hot reloading by installing nodemon globally and adding a dev script to npm run dev, so changes auto restart the server without manual restarts.
Define a product object type with name, description, quantity, price, and on sale fields, and implement a products query returning an array of these objects via a resolver.
Learn how to write a GraphQL query to fetch an array of product objects, selecting the image and product name fields using Apollo GraphQL Studio.
Learn to query a single product by id with a variable, returning name, description, price, and image. Implement a resolver that uses args.id to find the matching item.
Define a category type with id and name, create queries for all categories and a single category, and implement resolvers to return category data, preparing to relate categories to products.
Learn to query a category and its associated products by defining a category type with non-null products array and implementing a resolver that uses the parent id to filter products.
Define a many-to-one relation where every product has one category and each category can include multiple products, then fetch related category data via GraphQL resolvers.
Organize your GraphQL project by moving type definitions to a schema.js file, and splitting data into db.js and resolvers into a folder with query.js, category.js, and product.js.
Define a review type with id, date as string, title, comment, and rating; attach non-nullable reviews to product and implement a resolver that returns reviews by matching product ID.
Explore adding a filter object to GraphQL queries to retrieve only on-sale products, via a products filter input with an on sale status, applied to products and categories.
Learn how to implement filtering by average product rating in a Node GraphQL course, by aggregating review ratings, adding an average rating filter input, and applying it to product queries.
Explore how GraphQL mutations mutate data by updating, creating, or deleting records, and learn to implement mutations for categories, products, and reviews.
Define an add category mutation with an input that includes a name and a resolver that generates a uuid, add the category to data, and return category's id and name.
Define and test new GraphQL mutations to add products and reviews, with add product input, linking products to categories, and returning created items.
Learn to delete a category via mutation, returning a boolean, and handle associated products and reviews by setting the product category ID to null to avoid cascading deletions.
Learn to implement delete product with cascade to associated reviews in a GraphQL mutation, updating the schema to return a boolean and cascade deletions.
Implement the delete review mutation in GraphQL by filtering by id and returning a boolean, test the mutation, and confirm the targeted review is removed.
Update product and update review mutations, with nullable inputs and null returns, validate ids, and test changes to price, on sale status, and related fields in GraphQL.
Apply schema design rules to build a production-ready GraphQL API for grouping cars into manual and automatic groups, with join tables and publish controls.
Design a naive GraphQL schema for groups, defining id, name, image, body HTML, manual and automatic groups with feature rules and an apply-features-separately flag, focusing on schema over resolvers.
Start with a high level view of object types and their relationships to simplify the GraphQL schema, focusing on manual and automatic group, image, group membership, cars, and features.
Explain why the group membership object type is an implementation detail and why a GraphQL API should return cars within a specific group instead of the membership data.
Apply rule four by adding only necessary fields to your GraphQL API, such as id, features, apply features, car, name, image id, and body HTML, to avoid breaking changes.
Rule five groups closely related fields into a subobject, using a group feature set for manual and automatic groups with nonnullable arrays and a nullable feature set to simplify API.
Always check whether a list field should be paginated, such as a group's cars, to avoid huge, inefficient queries; use skip and take to load six at a time.
Always use object references instead of id fields in GraphQL, replacing image id with an image object that includes id and url for more useful client queries.
Choose field names that make sense to clients, not the underlying implementation, by renaming body HTML to description. This aligns GraphQL design with user understanding and avoids exposing implementation details.
Use enums to constrain feature fields to a set of values, replacing dynamic strings with options such as inline engine, four cylinder engine, twin engine, and red or black paint.
Split mutations by logical action: create and delete a group, update scalar fields, and separate publish and car-management actions like adding, sorting, and removing cars.
Split relationship mutations to handle one or many elements: add cars and remove cars mutations to flexibly update group and car relationships.
Prefix mutation names with the object for alphabetical grouping, e.g., group delete and group publish, and define inputs like group ID and car ID for operations.
Learn how to structure mutation inputs in GraphQL with Node to reduce duplication by introducing a reusable group input, using nullable fields, and requiring a group id for updates.
Create a group update payload for mutations that includes a nullable group and a user errors array, enabling business level errors via the user errors field.
Build a brand new project to create a full social media app with posts and authentication, using Postgres, Prisma, and TypeScript, while exploring GraphQL performance and frontend integration.
Set up an Apollo server with TypeScript to build your GraphQL API, learn that TypeScript is a superset of JavaScript, and use its type system to catch errors early.
Set up a GraphQL application with Apollo Server using TypeScript and ts-node dev. Initialize a node project with npm init -y, install the required dependencies, and enable hot reloading.
Set up an Apollo server to expose a GraphQL API with TypeScript, including tsconfig rules, gql type definitions, and resolvers, then centralize exports via an index for a scalable schema.
Set up a PostgreSQL database for a social media post app and show how GraphQL queries map to SQL, building posts, users, and profiles with one-to-many and one-to-one relations.
Learn how to spin up a Postgres database in the cloud using Heroku, avoiding local installation, provisioning a database, retrieving credentials, and connecting it to a GraphQL application.
Explore building a Postgres schema with posts, users, and profile tables, and connect it to a GraphQL API using prisma as an object-relational mapper, simplifying data queries.
Define post, user, and profile models in Prisma schema, apply IDs and defaults, establish 1-to-1 and 1-to-many relations, then push the schema and use Prisma Studio to visualize.
Establish one-to-many and one-to-one relationships by linking posts to users with foreign keys and a unique constraint for profiles, using Prisma relations and primary key references.
Define a GraphQL schema outlining post, user, and profile relationships, establish scalar types and non-null fields, and implement a post create mutation with an error payload using Prisma.
Create data with prisma by implementing a post creation resolver that returns a post or user errors via a post payload, using async/await and TypeScript types.
Learn to retrieve posts with Prisma by defining a posts query, using findMany with no conditions, and ordering by createdat descending to fetch the most recent posts.
Learn to implement a post update mutation with Prisma, using a nullable post input to update title and content, return the updated post or errors, and avoid input duplication.
Learn how to implement a post deletion mutation with Prisma, including validation, returning the deleted post and user errors, and testing the mutation.
Explore authentication and authorization, define identity, control who can create, read, update, or delete posts, and illustrate with Instagram's private profile and follow logic.
Implement a sign up mutation to create a user with email, name, password, and a required bio, wire auth resolvers with Prisma integration, and organize mutations for a GraphQL setup.
Discover how to secure passwords by hashing with bcrypt and salts, avoiding plain text storage in a GraphQL Node signup flow.
Explore implementing json web tokens for signup authentication in a GraphQL node app, returning a signed token, understanding header, payload, signature, and how the client uses it for protected requests.
Create the user and its profile using a Prisma profile create mutation with the bio and the user id, then verify the profile is linked to the user.
learn to identify the post author by extracting the user id from the authorization header's jwt and use it to replace the hardcoded author id in a create post mutation.
Learn to enforce authentication and authorization for post update and delete by building a canUserMutatePost utility that checks user and post ownership with Prisma and context.
Define publish and unpublish mutations for posts, enforce authentication and authorization, and implement resolvers to update the post's published status and return the updated post payload.
Learn to implement the MI query to retrieve the current user's information, such as email and ID, and expand the profile and posts queries for broader user data.
Implement a profile query to fetch a specific user's profile and related user information and posts, using a unique user ID and a profile resolver with Prisma to return data.
Explore relational post queries in GraphQL by linking posts to users using author id, building post and user resolvers, and handling published versus own profile post visibility.
Explore the N+1 problem in GraphQL by examining how querying posts and their users can trigger multiple database transactions, and learn why this inefficiency occurs.
Tackle the N+1 problem by batching and caching queries, reducing database transactions from many to just a few, using an in-memory store and data loaders.
Add a data loader to batch and cache resolver requests, using Prisma to fetch multiple users efficiently.
Connect a GraphQL API to a client by performing queries and mutations from a React app, using Apollo playground to test, and wire up posts, profiles, and auth routes.
Connect a React application to a GraphQL API using Apollo Client by installing dependencies, configuring a URI and in-memory cache, and wrapping the app with an Apollo Provider.
Master the first frontend GraphQL query in a React app with Apollo Client, fetching post title, content, createdAt, and username, then render posts using useQuery with loading and error handling.
Learn to fetch a profile and its posts by passing a dynamic user ID as a GraphQL variable, retrieving name, bio, and post details.
This lecture explains conditional rendering based on authentication status using a server-provided is my profile boolean to show an add post modal only for the profile owner.
Persist the auth token in local storage and pass it to the backend by configuring an Apollo auth link with setContext, attaching the authorization header to requests.
Learn to manage post visibility by authenticating, querying published status, and implementing publish and unpublish mutations using useMutation with Apollo Client and Gql, including user interface state updates.
Implement sign in and sign up flows with GraphQL mutations, pass credentials to obtain a token, store it in local storage, and handle errors.
Create a post by implementing a postCreate mutation with title and content, wiring Apollo useMutation, validating inputs, handling errors, and updating UI with the new post.
Complete the course by implementing the post delete and post update mutations in your React app, practice these mutations, and optionally enhance the user interface for a better user experience.
This course will teach you how to build a GraphQL API from absolute scratch. It is taught by a developer that has over 3 years of experience with GraphQL and has worked with it in multiple enterprise companies. By the end of this crash course, you will become an expert and know more than 99% of GraphQL hobbyists. This course isn't just aimed to teach you GraphQL, but how to properly utilize it in a real application. I hope you enjoy it!
We will be learning everything from scratch and thus you can be a GraphQL beginner to take this course. However, we will be using JavaScript as our primary language and thus some JS knowledge is ideal. We will also connect our server to the frontend and we will be using React as our client. Thus any frontend knowledge would be good but not unnecessary.
This course will teach you:
- What is GraphQL
- What are the benefits of GraphQL
- Learn GraphQL terminology
- How to build a GraphQL server
- Modern design principles
- Adding Authentication
- Working with Prisma v3 to interact with a Postgres DB
- Connecting GraphQL to the client
- Improve performance by learning about the n + 1 problem and solving it will data loaders