
Explore building a GraphQL API with Apollo Server on Node.js and MongoDB, covering queries, mutations, subscriptions, authentication, and efficient handling of deep nested queries with DataLoader and caching.
Download and install MongoDB community server, install Node.js, verify versions with mongo and node commands, and set up VS Code and Commander terminal for development.
Compare promises and async/await, showing how await simplifies asynchronous code, avoids callback hell, and improves error handling with try-catch.
Explore how the spread operator copies values from arrays, strings, and objects, merges arrays, and creates shallow copies to avoid shared references, with practical examples.
Learn object and array destructuring to extract properties and values into individual variables from a user object and an array, using curly braces for objects and square brackets for arrays.
GraphQL is a query language for your API that lets clients request exactly the data they need from a single endpoint, reducing multiple round trips.
Learn GraphQL schema basics, including scalar and object types, root types, and the roles of queries, mutations, and subscriptions. Discover input types, custom scalars, interfaces, unions, and enums.
Build a GraphQL API for task management with queries, mutations, and subscriptions. Secure access with authentication and authorization for authenticated users, and implement pagination and real-time updates with performance optimizations.
Set up a GraphQL server with Apollo Server and Express, define the schema with type definitions, configure dotenv and CORS, and expose a GraphQL endpoint with a playground.
Explore the GraphQL playground overview to test queries, view a self-documented schema, and learn to manage mutations, subscriptions, and settings.
Define a greetings query with a resolver in a GraphQL Apollo server, returning a string like hello, and use non-null and list modifiers to control nullability.
Define GraphQL type definitions for user and task, establish one-to-many user to tasks and many-to-one task to user, with fields such as name, email, task name, and isCompleted.
This lecture demonstrates building the list task query with dummy data, wiring constants for tasks and users, and exposing task fields and the user relation via GraphQL.
Define a field level resolver for the user to fetch the user object from the task, using parent, args, context, and info, and note its higher priority over query resolvers.
Implement a get task by id GraphQL query that accepts an id argument to fetch a task, returning its name and completed status, with the id serialized as a string.
Implement get all users and get user by id queries in a GraphQL Apollo server, using field resolvers to fetch associated tasks and test queries in the browser.
Implement the create task mutation by declaring a root mutation with a create task input, returning a task type, and pushing the task into a list with a unique uuid.
Modularize resolvers for the GraphQL Apollo Server by splitting user and task logic into separate files, exporting them, and wiring them into the server for clean, scalable APIs.
Learn how to implement GraphQL schema stitching by splitting user and task schemas into separate files, extending base query and mutation types, and integrating them into an Apollo server.
Install mongoose and implement a MongoDB connectivity utility that connects to localhost via a connection function using mongoose.connect with useNewUrlParser and useUnifiedTopology, logging success or errors.
Define user and task Mongoose schemas with name, email, password, and a task list; establish a many-to-one relation from task to user and enable automatic timestamps.
Implement a signup mutation in a GraphQL API with Node.js and MongoDB, defining sign up input, checking email uniqueness, hashing passwords, and saving via Mongoose.
Implement a custom date scalar in a GraphQL Apollo server to handle ISO date times, wire it into the schema, and apply it to user date fields.
Learn to implement the login mutation to authenticate users, return a token, and use it to protect other APIs in a GraphQL API built with node.js and mongodb.
Learn how the resolver context in GraphQL Apollo Server shares data like authentication state across resolvers, and why defining context as a function enables per-request evaluation.
Verify the token from the authorization header and set the user context in a GraphQL Apollo Server. The lecture covers JWT verification, payload extraction, and attaching the user email.
Learn to implement resolver middleware in a GraphQL Apollo server to centralize authentication logic. Use a combineResolvers utility and an isAuthenticated middleware to enforce access and reuse checks across resolvers.
Update get user by id to use the logged-in user's authentication state, fetch by email, and populate tasks via the task model in GraphQL.
Update the create task mutation to link the new task to the logged-in user by saving the task and pushing its id to the user's task list.
Update to implement list task and get task by id in a GraphQL API, enforce authentication, owner-based access, and use context to expose logged-in user id for tasks.
Implement the update task mutation in a GraphQL Apollo Server with Node.js and MongoDB, updating fields like name and completed and returning the updated task.
Implement a delete task mutation in a GraphQL Apollo Server with Node.js and MongoDB, including delaying tasks, updating the user's task array, and cleaning up references.
Implement offset–limit pagination using skip and limit with defaults, sort results in descending order, and explore drawbacks like duplicates and performance, setting the stage for cursor-based pagination in a video.
This lecture compares offset limit pagination with cursor-based pagination, showing how updates cause duplicates in offset paging and how cursor anchors enable consistent, faster results.
Implement cursor-based pagination in a GraphQL API using a client cursor to fetch the next tasks. Expose pageInfo including nextPageCursor and hasNextPage, and base64-encode the cursor to hide details.
Explore why field-level resolvers can cause repeated data fetches and bottlenecks, and how data loaders from Facebook batch and cache GraphQL requests to reduce database hits.
Implement data loaders to batch and resolve requests with a batch loading function that accepts keys and returns a promise, reducing database hits.
Configure a real-time user subscription in apollo server with node.js and mongodb, enabling websockets, publishing user created events on signup, and testing live updates.
Learn to format GraphQL error responses with Apollo Server's formatError, exposing only the message, and reuse dynamic values using query variables in queries, mutations, and subscriptions.
Explore the source code of a GraphQL API built with Apollo Server, Node.js, and MongoDB.
Build GraphQL API with Apollo Server in Node.js, Express, and MongoDB Database.
ϟ What is GraphQL?
GraphQL is a query language for APIs and a runtime for fulfilling those queries with your existing data. GraphQL provides a complete and understandable description of the data in your API, gives clients the power to ask for exactly what they need, and nothing more, makes it easier to evolve APIs over time, and enables powerful developer tools.
♦ Ask for what you need, get exactly that.
♦ Get many resources in a single request.
♦ Describe what’s possible with a type system.
♦ Move faster with powerful developer tools.
♦ Evolve your API without versions
♦ Bring your own data and code
ϟ Who is using GraphQL?
♦ Facebook, Github, Pinterest, Shopify and more
ϟ What is Apollo Server?
Apollo Server is the best way to quickly build a production-ready, self-documenting API for GraphQL clients, using data from any source.
It's open-source and works great as a stand-alone server, an add-on to an existing Node.js HTTP server, or in "serverless" environments.
Apollo Server implements a spec-compliant GraphQL server which can be queried from any GraphQL client, including Apollo Client, enabling:
♦ An easy start, so front-end and back-end developers can start fetching data quickly.
♦ Incremental adoption, allowing advanced features to be added when they're needed.
♦ Universal compatibility with any data source, any build tool, and any GraphQL client.
♦ Production readiness, and what you build in development works great in production.
You will learn the following things in the course:
♦ Build GraphQL API with Apollo Server in Node.js, Express, and MongoDB.
♦ Add JWT Authentication in Apollo GraphQL API.
♦ Implement Faster pagination with Cursor Based Pagination Strategy. We will also implement offset limit pagination and will compare them.
♦ Add Data Loaders to return data faster from the server with batching and caching your database query.
♦ Feel Confident with GraphQL Concepts such as Query, Mutation, and Subscription.
♦ Best practices in GraphQL and Build Scalable API with proper schema design.
♦ Efficient and scalable GraphQL Schema design strategies.
♦ Learn to handle deep nested GraphQL Query.
♦ Learn to efficiently use the GraphQL Playground tool.
♦ Get a good understanding of schemas, "types" in GraphQL.
♦ Learn to set up real-time communication between client and server with the subscription.
♦ Learn to manage the authentication context in GraphQL.
♦ Secure/Protect various query and mutations with Graphql Resolver middleware and auth state from context.
♦ Define relationships between various object types.
♦ and much more.