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.

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
We all love GraphQL, but it can be daunting to get a server up and running and keep your code organized, maintainable, and testable over the long term. No more! Come watch as I go from an empty directory to a fully fledged GraphQL API in minutes flat. Plus, see how easy it is to use and create directives to clean up your code even more. You're gonna love GraphQL even more once you make things Redwood Easy!
Full Stack Components
Remix Conf Europe 2022Remix Conf Europe 2022
37 min
Full Stack Components
Top Content
Remix is a web framework that gives you the simple mental model of a Multi-Page App (MPA) but the power and capabilities of a Single-Page App (SPA). One of the big challenges of SPAs is network management resulting in a great deal of indirection and buggy code. This is especially noticeable in application state which Remix completely eliminates, but it's also an issue in individual components that communicate with a single-purpose backend endpoint (like a combobox search for example).
In this talk, Kent will demonstrate how Remix enables you to build complex UI components that are connected to a backend in the simplest and most powerful way you've ever seen. Leaving you time to chill with your family or whatever else you do for fun.
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
How many times did you implement the same flow in your application: check, if data is already fetched from the server, if yes - render the data, if not - fetch this data and then render it? I think I've done it more than ten times myself and I've seen the question about this flow more than fifty times. Unfortunately, our go-to state management library, Vuex, doesn't provide any solution for this.For GraphQL-based application, there was an alternative to use Apollo client that provided tools for working with the cache. But what if you use REST? Luckily, now we have a Vue alternative to a react-query library that provides a nice solution for working with server cache. In this talk, I will explain the distinction between local application state and local server cache and do some live coding to show how to work with the latter.
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
Tired of rebuilding your React-based web framework from scratch for every new project? You're in luck! RedwoodJS is a full-stack web application framework (think Rails but for JS/TS devs) based on React, Apollo GraphQL, and Prisma 2. We do the heavy integration work so you don't have to. We also beautifully integrate Jest and Storybook, and offer built-in solutions for declarative data fetching, authentication, pre-rendering, logging, a11y, and tons more. Deploy to Netlify, Vercel, or go oldschool on AWS or bare metal. In this talk you'll learn about the RedwoodJS architecture, see core features in action, and walk away with a sense of wonder and awe in your heart.
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
Do you know what’s really going on in your node_modules folder? Software supply chain attacks have exploded over the past 12 months and they’re only accelerating in 2022 and beyond. We’ll dive into examples of recent supply chain attacks and what concrete steps you can take to protect your team from this emerging threat.
You can check the slides for Feross' talk here.
Towards a Standard Library for JavaScript Runtimes
Node Congress 2022Node Congress 2022
34 min
Towards a Standard Library for JavaScript Runtimes
Top Content
You can check the slides for James' talk here.

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.
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.
Relational Database Modeling for GraphQL
GraphQL Galaxy 2020GraphQL Galaxy 2020
106 min
Relational Database Modeling for GraphQL
Top Content
WorkshopFree
Adron Hall
Adron Hall
In this workshop we'll dig deeper into data modeling. We'll start with a discussion about various database types and how they map to GraphQL. Once that groundwork is laid out, the focus will shift to specific types of databases and how to build data models that work best for GraphQL within various scenarios.
Table of contentsPart 1 - Hour 1      a. Relational Database Data Modeling      b. Comparing Relational and NoSQL Databases      c. GraphQL with the Database in mindPart 2 - Hour 2      a. Designing Relational Data Models      b. Relationship, Building MultijoinsTables      c. GraphQL & Relational Data Modeling Query Complexities
Prerequisites      a. Data modeling tool. The trainer will be using dbdiagram      b. Postgres, albeit no need to install this locally, as I'll be using a Postgres Dicker image, from Docker Hub for all examples      c. Hasura