Full-stack JS today: Fastify, GraphQL and React

Rate this content
Bookmark

First there was LAMP, then there was MEAN and JAM. But now it’s 2022 and times have changed… What does the modern full stack look like? It’s built entirely from free and open source technologies, it’s scalable beyond imagination, it can run on premise or in the cloud, it should get out of the way and not lead to vendor lock-in, and most importantly it should “just work.” There are so many tools to choose from. Choosing the right stack from day one can be the difference from project success to smoldering pile of software ashes. Using fastify, mercurius, urql, and react we can build high performance full-stack applications using all javascript technologies.

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

FAQ

Cody's talk is about building a modern full-stack application with JavaScript, focusing on GraphQL and using open-source technologies.

Cody works at NearForm and teaches a web development course at a local university in France.

The 80-20 rule, also known as the Pareto Principle, suggests that 80% of outcomes come from 20% of the inputs or efforts. Cody emphasizes focusing on the difficult 20% of non-functional requirements to improve productivity.

Cody suggests starting from the back (i.e., the backend) to better address non-functional requirements that usually cause challenges towards the end of a project. This approach aims to build a more robust and adaptable tech stack.

Cody recommends modularity, developer experience, community support (open-source), and transparency as key principles for building an effective tech stack.

Cody favors PostgreSQL because it is a powerful relational database that supports JSON, making it versatile for both relational and document-based data models. It also offers features like connection pooling and is easy to run locally or in Docker.

Cody recommends Fastify as the server framework due to its modularity, ease of use, and ability to evolve from monolithic applications to microservices. It is also open-source and has a robust plugin architecture.

Mercurius is a GraphQL server plugin for Fastify. It is used in the tech stack because it supports real-world GraphQL problems like caching, federation, authentication, and subscriptions out of the box.

Cody prefers Urql for the client-side GraphQL library because it supports major front-end libraries like React, offers advanced caching mechanisms, and includes offline support and a hooks API for easy integration with React.

Cody believes that open-source technologies are more secure and reliable because they have more community involvement, which leads to faster bug fixes and better transparency. Open-source projects also allow for greater customization and adaptability.

Cody Zuschlag
Cody Zuschlag
25 min
17 Jun, 2022

Comments

Sign in or register to post your comment.

Video Summary and Transcription

The Talk discusses building a modern full stack application with JavaScript and GraphQL, emphasizing the importance of prioritizing the critical 20% of challenges. It highlights the benefits of building a productive and transparent tech stack with modularity and developer-friendly tools. The use of PostGrey as a relational database and Fastify as a server framework is recommended. The Talk also explores the advantages of using Mercurius and Urql for GraphQL implementation. Additionally, it mentions the use of React, SSR, and Fastify Vite for full-stack SSR and modular components. The Talk concludes by mentioning the advantages of this stack for complex functionality and the possibility of using Fastify in a serverless infrastructure.

1. Building a Modern Full Stack Application

Short description:

I'll be talking about building a modern full stack application with JavaScript and GraphQL. Let's focus on the last 20% of the project, the hard part that we often overlook. The Prado Principle, introduced by Vilfredo Prado, states that 80% of our outcomes come from 20% of the challenges. Steve Jobs applied this principle at Apple, reducing the number of computer models and devices. Let's learn from this and prioritize the critical 20% from the beginning.

So happy to be here. Thanks, everyone. I'll be talking about building a modern full stack application with JavaScript and a little spoiler, we're going to be talking about GraphQL, all open source, because that's what we love. My name is Cody, I work at NearForm, I teach web development course at the local university where I live in France, but enough about me. What I really want to do is I want to challenge everyone here, do a little exercise with me.

Close your eyes and imagine your next project. You've got all the requirements in from your stakeholders, you know what you want to build, and what are you going to do when you close your eyes? You're going to start thinking about those tools and those frameworks that you're going to reach for. When I do this, and I start thinking about those tools and frameworks, what I'm saying to myself is this time it's going to be different. This time it's going to be right, this time it's going to be rainbows, and this time it's going to be unicorns.

I think we all do that because we want to reach for new technology that's going to help, it's going to solve all of those problems that we had in our last project. I think the trap is, though, is we might get like 80 per cent through our project. When we reach that 80 per cent, all of a sudden something happens. Those real-world non-functional requirements hit that last 20 per cent, and it's that last 20 per cent that's really hard. Where do we find ourselves? We are thinking about rainbows and unicorns, we end up with something like this. I don't know how many times I've been like this, trying to fix real problems in a production application. We've got complex CI pipelines, we've got problems with scaling, we've got problems with performance, security things we didn't think about in the beginning, authorisation, authentication, so I feel like there's this massive gap between what we imagined and the reality, because we are all just real-world people fixing real-world problems. We're devs, we're trying to do the best we can, and I think what I want to challenge us to do today, let's focus in on that last 20 per cent, that hard 20 per cent that we don't always think about in the beginning.

So, I want to talk about this guy. This guy, his name is Vilfredo Prado. We call it the Prado Principle. I know you can't read that text but you will in just a second. Vilfredo Prado, this Italian economist, he came up with the idea of the 80-20 rule. I keep talking about these percentages and he said, you know, like, maybe just 80 per cent of our outcomes in our projects are going to come from 20 per cent of the challenges, of the requirements. That's what I want to challenge us to do today. Let's think about that 20 per cent from the beginning. So there's the Prado Principle in its entirety. And I think Steve Jobs knew this. When he came back to Apple in 1996, they had like 15 desktop computer models, he cut them down to one. They had a whole bunch of portable devices, I think they called them laptops back in 1996, he cut them down to one. Peripherals, printers, deleted them all.

2. Building a Productive and Transparent Tech Stack

Short description:

I want to focus on the hard 20% that can lead to an 80% increase in productivity. Building a tech stack with modularity allows us to adapt to evolving requirements. Developer experience is crucial, with tools that guide rather than hinder. Running applications anywhere, without reliance on cloud services, is important. Community-supported, open-source projects provide security and transparency.

Got rid of them all. He wanted to focus in on that last 20 per cent, that last 20 per cent that really mattered. So today, what I want to focus on, what I want to challenge us to focus on is that hard 20 per cent. And maybe, just maybe, we can gain 80 per cent in our productivity.

So how can we build this tech stack, this magic tech stack, that's going to focus in on that hard 20 per cent, that 20 per cent of non-functional requirements, help us get speed of delivery and ensure that our production-grade application can work the way that we want, that we can fix things while it's in production? To do that, I want to lay out some principles when I'm going to build my tech stack. These are the principles I'm going to think about. The first one's going to be modularity. And I think one of the challenges, the traps that we can fall into, is we're going to reach for that framework that says it does it all, and we think it's going to do it all, but maybe it doesn't do it all. What happens when we hit that moment when it doesn't do something we want, and we have We have to reach for something else, or throw away the framework and start from the beginning. So if we can build a tech stack where we can swap out layers of the stack when something isn't working, we've won something, right? Like our stack suddenly becomes modular and we can adapt to the situation, to the requirements as they evolve.

Next up on our principles is going to be developer experience. That's why we're here. We're all devs. We're all fixing real things. I want the tools like help me, like guide me, not get in the way, right? And I want to be able to run my application anywhere. I want to be able to run it on my laptop while I'm in the train, when I don't have Wi-Fi or the airplane, like it needs to run locally or in the cloud, on site, docker, whatever it is. That's really important to me, too. I don't want to be reliant on some cloud services and I can't run my end to end tests on my machine because I'm reliant on that internet connection that doesn't exist in the hotel. Based on my principles, it's community first. I'm talking about open source projects. Community supported. They're going to be more secure, ideally, right? Because more people, more eyes are looking at the code. Bugs are going to get fixed. Things aren't hidden from you. I think that's really important when it comes to a tech stack. I'm talking about a hundred percent open source. Not just that 80% and 20% of the magic secret sauce is running in a cloud service that nobody can see. I want to see 100% open source. My next and last principle is going to be transparency. This is related to open source and that idea of a community supported project.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

From GraphQL Zero to GraphQL Hero with RedwoodJS
GraphQL Galaxy 2021GraphQL Galaxy 2021
32 min
From GraphQL Zero to GraphQL Hero with RedwoodJS
Top Content
Tom Pressenwurter introduces Redwood.js, a full stack app framework for building GraphQL APIs easily and maintainably. He demonstrates a Redwood.js application with a React-based front end and a Node.js API. Redwood.js offers a simplified folder structure and schema for organizing the application. It provides easy data manipulation and CRUD operations through GraphQL functions. Redwood.js allows for easy implementation of new queries and directives, including authentication and limiting access to data. It is a stable and production-ready framework that integrates well with other front-end technologies.
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
RemixConf EU discussed full stack components and their benefits, such as marrying the backend and UI in the same file. The talk demonstrated the implementation of a combo box with search functionality using Remix and the Downshift library. It also highlighted the ease of creating resource routes in Remix and the importance of code organization and maintainability in full stack components. The speaker expressed gratitude towards the audience and discussed the future of Remix, including its acquisition by Shopify and the potential for collaboration with Hydrogen.
Local State and Server Cache: Finding a Balance
Vue.js London Live 2021Vue.js London Live 2021
24 min
Local State and Server Cache: Finding a Balance
Top Content
This Talk discusses handling local state in software development, particularly when dealing with asynchronous behavior and API requests. It explores the challenges of managing global state and the need for actions when handling server data. The Talk also highlights the issue of fetching data not in Vuex and the challenges of keeping data up-to-date in Vuex. It mentions alternative tools like Apollo Client and React Query for handling local state. The Talk concludes with a discussion on GitLab going public and the celebration that followed.
RedwoodJS: The Full-Stack React App Framework of Your Dreams
React Summit Remote Edition 2021React Summit Remote Edition 2021
43 min
RedwoodJS: The Full-Stack React App Framework of Your Dreams
Top Content
Redwood JS is a full stack React app framework that simplifies development and testing. It uses a directory structure to organize code and provides easy data fetching with cells. Redwood eliminates boilerplate and integrates Jest and Storybook. It supports pre-rendering and provides solutions for authentication and deployment. Redwood is a cross-client framework that allows for building web and mobile applications without duplicating work.
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Node Congress 2022Node Congress 2022
26 min
It's a Jungle Out There: What's Really Going on Inside Your Node_Modules Folder
Top Content
The talk discusses the importance of supply chain security in the open source ecosystem, highlighting the risks of relying on open source code without proper code review. It explores the trend of supply chain attacks and the need for a new approach to detect and block malicious dependencies. The talk also introduces Socket, a tool that assesses the security of packages and provides automation and analysis to protect against malware and supply chain attacks. It emphasizes the need to prioritize security in software development and offers insights into potential solutions such as realms and Deno's command line flags.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
There is a need for a standard library of APIs for JavaScript runtimes, as there are currently multiple ways to perform fundamental tasks like base64 encoding. JavaScript runtimes have historically lacked a standard library, causing friction and difficulty for developers. The idea of a small core has both benefits and drawbacks, with some runtimes abusing it to limit innovation. There is a misalignment between Node and web browsers in terms of functionality and API standards. The proposal is to involve browser developers in conversations about API standardization and to create a common standard library for JavaScript runtimes.

Workshops on related topic

Build with SvelteKit and GraphQL
GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Top Content
Featured WorkshopFree
Scott Spence
Scott Spence
Have you ever thought about building something that doesn't require a lot of boilerplate with a tiny bundle size? In this workshop, Scott Spence will go from hello world to covering routing and using endpoints in SvelteKit. You'll set up a backend GraphQL API then use GraphQL queries with SvelteKit to display the GraphQL API data. You'll build a fast secure project that uses SvelteKit's features, then deploy it as a fully static site. This course is for the Svelte curious who haven't had extensive experience with SvelteKit and want a deeper understanding of how to use it in practical applications.

Table of contents:
- Kick-off and Svelte introduction
- Initialise frontend project
- Tour of the SvelteKit skeleton project
- Configure backend project
- Query Data with GraphQL
- Fetching data to the frontend with GraphQL
- Styling
- Svelte directives
- Routing in SvelteKit
- Endpoints in SvelteKit
- Deploying to Netlify
- Navigation
- Mutations in GraphCMS
- Sending GraphQL Mutations via SvelteKit
- Q&A
Developing Dynamic Blogs with SvelteKit & Storyblok: A Hands-on Workshop
JSNation 2023JSNation 2023
174 min
Developing Dynamic Blogs with SvelteKit & Storyblok: A Hands-on Workshop
Top Content
Featured WorkshopFree
Alba Silvente Fuentes
Roberto Butti
2 authors
This SvelteKit workshop explores the integration of 3rd party services, such as Storyblok, in a SvelteKit project. Participants will learn how to create a SvelteKit project, leverage Svelte components, and connect to external APIs. The workshop covers important concepts including SSR, CSR, static site generation, and deploying the application using adapters. By the end of the workshop, attendees will have a solid understanding of building SvelteKit applications with API integrations and be prepared for deployment.
Build Modern Applications Using GraphQL and Javascript
Node Congress 2024Node Congress 2024
152 min
Build Modern Applications Using GraphQL and Javascript
Featured Workshop
Emanuel Scirlet
Miguel Henriques
2 authors
Come and learn how you can supercharge your modern and secure applications using GraphQL and Javascript. In this workshop we will build a GraphQL API and we will demonstrate the benefits of the query language for APIs and what use cases that are fit for it. Basic Javascript knowledge required.
End-To-End Type Safety with React, GraphQL & Prisma
React Advanced Conference 2022React Advanced Conference 2022
95 min
End-To-End Type Safety with React, GraphQL & Prisma
Featured WorkshopFree
Sabin Adams
Sabin Adams
In this workshop, you will get a first-hand look at what end-to-end type safety is and why it is important. To accomplish this, you’ll be building a GraphQL API using modern, relevant tools which will be consumed by a React client.
Prerequisites: - Node.js installed on your machine (12.2.X / 14.X)- It is recommended (but not required) to use VS Code for the practical tasks- An IDE installed (VSCode recommended)- (Good to have)*A basic understanding of Node.js, React, and TypeScript
GraphQL for React Developers
GraphQL Galaxy 2022GraphQL Galaxy 2022
112 min
GraphQL for React Developers
Featured Workshop
Roy Derks
Roy Derks
There are many advantages to using GraphQL as a datasource for frontend development, compared to REST APIs. We developers in example need to write a lot of imperative code to retrieve data to display in our applications and handle state. With GraphQL you cannot only decrease the amount of code needed around data fetching and state-management you'll also get increased flexibility, better performance and most of all an improved developer experience. In this workshop you'll learn how GraphQL can improve your work as a frontend developer and how to handle GraphQL in your frontend React application.
Build a Headless WordPress App with Next.js and WPGraphQL
React Summit 2022React Summit 2022
173 min
Build a Headless WordPress App with Next.js and WPGraphQL
Top Content
WorkshopFree
Kellen Mace
Kellen Mace
In this workshop, you’ll learn how to build a Next.js app that uses Apollo Client to fetch data from a headless WordPress backend and use it to render the pages of your app. You’ll learn when you should consider a headless WordPress architecture, how to turn a WordPress backend into a GraphQL server, how to compose queries using the GraphiQL IDE, how to colocate GraphQL fragments with your components, and more.