GraphQL - From Zero to Hero in 3 hours

certificate
Recording and certification are available to Multipass and Full ticket holders only
Please login if you have one.
Rate this content
Bookmark
This video covers the usage of GraphQL with Next.js and Node.js, focusing on creating efficient APIs. It explains the setup of Postgres and the use of TypeORM for database management. The speaker discusses the snake naming strategy for mapping TypeScript classes to Postgres tables and the importance of the EntityManager in TypeORM for handling transactions. The video also covers server-side rendering and static site rendering in Next.js, using the Apollo Client for accessing GraphQL APIs. Additionally, the video highlights the use of Apollo Client DevTools and Altair for debugging and writing queries. The speaker demonstrates creating a new entity called 'peer' in the GraphQL API, generating a complete CRUD resource for it, and updating the app module accordingly. The video also touches on the importance of using a transactional EntityManager for atomic operations and the benefits of TypeORM in NestJS applications.

From Author:

How to build a fullstack GraphQL application (Postgres + NestJs + React) in the shortest time possible.


All beginnings are hard. Even harder than choosing the technology is often developing a suitable architecture. Especially when it comes to GraphQL.


In this workshop, you will get a variety of best practices that you would normally have to work through over a number of projects - all in just three hours.


If you've always wanted to participate in a hackathon to get something up and running in the shortest amount of time - then take an active part in this workshop, and participate in the thought processes of the trainer.

This workshop has been presented at React Summit 2022, check out the latest edition of this React Conference.

FAQ

In a NestJS application, the resolver acts as the firewall, interfacing between the client and the server. It handles GraphQL queries and mutations, ensuring that operations like data fetching and updates are executed properly. The resolver is responsible for defining and managing GraphQL endpoints.

In NestJS, you can generate a CRUD resource using the Nest CLI command `nest g resource [name]`. This command sets up a new module with all necessary files and configurations for creating, reading, updating, and deleting resources. You can specify additional options such as `--no-rest` and `--graphql-code-first` to tailor the resource to your needs.

TypeORM integrates seamlessly with NestJS, providing features such as automatic table creation (entities), complex data handling, and transaction management. It supports active record and data mapper patterns, making it versatile for different development styles. TypeORM simplifies database interactions and ensures data integrity across transactions.

In GraphQL within a NestJS application, errors are handled through exceptions. When an error occurs, GraphQL returns an error response that includes messages detailing the issue. Developers can throw custom exceptions in their resolvers or services, which GraphQL will catch and format appropriately in the response.

The `EntityManager` in TypeORM is responsible for managing database operations involving entities. It handles the lifecycle of entities, from creation and updates to deletion, and provides methods for querying and interacting with the database. The EntityManager ensures that all operations are consistent and transaction-safe.

To enhance the performance of GraphQL queries in NestJS, use efficient resolvers, implement caching strategies, and optimize data fetching with techniques like batching and limiting fields returned in queries. Additionally, consider using DataLoader to batch and cache requests, reducing the number of database hits.

Next.js offers several rendering methods, including server-side rendering (SSR), static site generation (SSG), and client-side rendering. SSR dynamically generates HTML for each request, SSG pre-renders pages at build time, and client-side rendering fetches data and renders content in the browser, enhancing interactive experiences.

Pawel Sawicki
Pawel Sawicki
164 min
04 Jul, 2022

Comments

Sign in or register to post your comment.

Video Transcription

Video transcription and chapters available for users with access.