GraphQL and React - Two Great Tastes that Taste Great Together

Bookmark

As a full-stack engineer with a bias towards the database...and a career spent working with and evangelizing database and distributed systems...why GraphQL? In this talk, I will share some of my personal journey with React, GraphQL, their respective communities, and my point-of-view on the future.

9 min
17 Jun, 2021

AI Generated Video Summary

React's JavaScript extension allows you to write JavaScript in the JavaScript editor, providing flexibility for any type of application. The use of React and GraphQL in enterprise applications resulted in improved code maintenance, design acumen, and code reuse. Building teams of passionate individuals interested in React and GraphQL solidified the argument for using these libraries. The integration of React and GraphQL with modern development paradigms like Reactive and event-based programming was seamless. Existing reference materials and community-based resources facilitated the quick onboarding of new team members.

1. Introduction to React's JavaScript Extension

Short description:

In this video, we'll take a look at React's JavaScript extension, which lets you write JavaScript in the JavaScript editor. It's a cloud-based extension that allows you to write JavaScript with any language, and to use it in any type of application.

In this video, we'll take a look at React's JavaScript extension, which lets you write JavaScript in the JavaScript editor. We'll be sharing it with you in another video, so don't forget to check it out and subscribe to our channel for more!

So, what is a JavaScript extension? It's a cloud-based extension that allows you to write JavaScript with any language, and also in one language. So what does it do? It allows you to write JavaScript with any language, and to use it in any type of application. So, let's take a look.

2. React and GraphQL Benefits

Short description:

Hey, I'm Adrian, and I'm going to talk to you about React and GraphQL. I'll share two stories of my own that highlight the benefits of using these technologies. The first story is about an IoT devices project where we needed to replace a native Windows app with a web interface. The second story involves a reporting interfaces project with various data sources and databases. By using React and GraphQL, we found that we had access to effective software development patterns, improved data fetching, and better utilization of mutators and accessors. We also benefited from the familiarity of existing development staff with patterns like data transfer object and data access object. Additionally, GraphQL allowed us to avoid lock-in and achieve component reuse, while React and GraphQL seamlessly integrated with modern development paradigms like Reactive and event-based programming.

Hey, I'm Adrian, and I'm going to talk to you about 2 great tastes that go great together. Like eggs and bacon for breakfast, or rice with a nice fried egg, and other delicious ingredients in bim-bim-bap, or naan and curry. Great things, great tastes, all match together.

In this situation, though, I'm talking about React and GraphQL, and I'm going to tell you about two stories of my own that are basic anecdotes of what I went through to make the argument for React and GraphQL to be used on projects. Specifically, an IoT devices project, little RFID chips were being used inside of massive warehouses and across geographic areas to track e-commerce products and things like that, and also just containers of things within an overall warehouse and their movement in and out of a place. We needed an interface to be built that would replace a Windows app. It was a native Windows app. I believe it ran on Windows 95, Windows 98. So a little on the older side these days, but we wanted to bring it to the web so that people could use it not just on a Windows desktop, but out on the web anywhere.

And then the other project is a reporting interfaces project where we had all these disparate data sources and different databases like Postgres and MySQL, Apache Cassandra, and other things. Some of the databases were even so distinctive and kind of old that they were like multivalue databases. Who's heard of that? It's not even a used thing anymore. But one database was 30-something years old, and we got a GraphQL interface over that and used it in this project.

So, why React and GraphQL? Why did I push for that on these projects? The key thing is this basic list that I'm going to give you. It started out with just mentioning the patterns and practices that we got kind of out of the box with both of these libraries. With React and GraphQL, there's a lot of pieces that are used that just immediately use patterns that are very effective for software development. Then beyond that, as with patterns, we got a lot of repeatability and reuse out of those pieces within those libraries. But it also helped us to expand past that and avoid a lot of overfetching or underfetching of data. That's one of the great benefits of GraphQL. It really helps you kind of hone in on what you're trying to get and work with your data. And then beyond that, we also kind of honed in even more on the way we use mutators, accessors, and all of these things to get that data and what we were doing with that data. It helped a lot. Then we used a lot of patterns like data transfer object and data access object that a lot of the existing development staff already were familiar with. They weren't quite always familiar with, say, GraphQL or maybe React, but they were able to ramp up really quickly because of the existing familiarity with patterns they had used in the past. Then moving on beyond that, we got rid of a lot of the what-ifs, such as, what if we are going to use this database forever and we're going to shift it to this other database? Are we tied to it? Do we have lock-in? Well, GraphQL just knocked that right out of the door. We're not locked into anything because we're building a tier over the database. And then we get a lot of component reuse and things like that where it's more easy to follow things like that single responsibility pattern for the React components. And then, moving even further, a lot of those modern development paradigms around Reactive and event-based programming are easy to use with GraphQL and React, because a lot of it is the native way those libraries would do something, being that they're both built focused around the asynchronous web. So, just the inherent nature of the way they work makes that even more possible and easier to implement with Reactive. So, kind of bringing all that back around, that laundry list of things back around, and doing a little back-of-the-napkin math, as one might say.

3. Benefits of React and GraphQL

Short description:

I've built 40-plus enterprise applications and was able to make the argument for using React and GraphQL for two specific projects. By using these libraries, we achieved better overall code maintenance and design acumen. Building teams of passionate individuals interested in React and GraphQL solidified the argument for using these libraries. Additionally, React and GraphQL reduced the Not Invented Here syndrome and allowed us to implement patterns that increased code reuse and reliability. We were able to ramp up new team members quickly by providing existing reference materials and community-based resources.

I've built 40-plus enterprise applications. And that was just two that, specifically, I was able to make the argument for and get React and GraphQL used for those specific projects. And in my experience, from those other enterprise applications being developed, and us going with React and GraphQL to develop those two specific applications, which were very different, very different applications, we got better overall code maintenance. We got better design and pattern use acumen across the projects.

And a lot of that had to do specifically with using those libraries. And it was also because we had great teams. And as I mentioned here on this slide, in the strategic advantage section, one of the big things was that we were able to build teams of people that were really passionate and interested in using this technology specifically. They were interested in React and they were interested in GraphQL. So building a team with people that were very interested in using the tech and interested in doing things within a domain with that tech really helped to kind of just firm up the argument to use these libraries.

And then finally the tactical things were really just the icing on the cake. Being able to get rid of the situation where developers routinely felt like they needed to reinvent something because pieces just weren't there. But with this, with React and GraphQL, it dramatically reduced the NIH or Not Invented Here syndrome. And then, also, beyond just having those existing patterns being put into place and being available that are used in React and GraphQL libraries, we were able to implement patterns over that that increased reuse, reliability, consistency of the code base, and getting people ramped up as we brought people onto the teams. We were able to get them ramped up more easily by providing reference material that already exists and community-based material that already exists to get them up to speed. And that helped the existing team members keep moving on the project and at the same time ramp up new people to start contributing almost immediately, at least, in some cases, within hours of being brought on board.

So that is two of the projects. And the TLDR of that is using React and GraphQL. Position a project ahead of the timeline. Put you in a very good position. Thanks for giving my talk a listen. I'm Adrian. You can find me at GitHub or Twitter as Adrian. I enjoy the privilege to work with the awesome Hasura team building, supporting, and advocating for the amazing GraphQL engine. And we are hosting a GraphQL conference where we are inviting senior engineers and leaders from Fortune 500 companies to learn how to use GraphQL to help them build apps faster. Learn how to use GraphQL. Come join us. Sign up and register at Enterprise GraphQL. There's the Bitly link. I'm Adrian. Thanks for listening.

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

React Summit Remote Edition 2021React Summit Remote Edition 2021
33 min
Building Better Websites with Remix
Remix is a new web framework from the creators of React Router that helps you build better, faster websites through a solid understanding of web fundamentals. Remix takes care of the heavy lifting like server rendering, code splitting, prefetching, and navigation and leaves you with the fun part: building something awesome!
React Advanced Conference 2022React Advanced Conference 2022
25 min
A Guide to React Rendering Behavior
React is a library for "rendering" UI from components, but many users find themselves confused about how React rendering actually works. What do terms like "rendering", "reconciliation", "Fibers", and "committing" actually mean? When do renders happen? How does Context affect rendering, and how do libraries like Redux cause updates? In this talk, we'll clear up the confusion and provide a solid foundation for understanding when, why, and how React renders. We'll look at: - What "rendering" actually is - How React queues renders and the standard rendering behavior - How keys and component types are used in rendering - Techniques for optimizing render performance - How context usage affects rendering behavior| - How external libraries tie into React rendering
React Advanced Conference 2022React Advanced Conference 2022
30 min
Using useEffect Effectively
Can useEffect affect your codebase negatively? From fetching data to fighting with imperative APIs, side effects are one of the biggest sources of frustration in web app development. And let’s be honest, putting everything in useEffect hooks doesn’t help much. In this talk, we'll demystify the useEffect hook and get a better understanding of when (and when not) to use it, as well as discover how declarative effects can make effect management more maintainable in even the most complex React apps.
React Summit 2022React Summit 2022
20 min
Routing in React 18 and Beyond
Concurrent React and Server Components are changing the way we think about routing, rendering, and fetching in web applications. Next.js recently shared part of its vision to help developers adopt these new React features and take advantage of the benefits they unlock.
In this talk, we’ll explore the past, present and future of routing in front-end applications and discuss how new features in React and Next.js can help us architect more performant and feature-rich applications.
React Advanced Conference 2021React Advanced Conference 2021
27 min
(Easier) Interactive Data Visualization in React
If you’re building a dashboard, analytics platform, or any web app where you need to give your users insight into their data, you need beautiful, custom, interactive data visualizations in your React app. But building visualizations hand with a low-level library like D3 can be a huge headache, involving lots of wheel-reinventing. In this talk, we’ll see how data viz development can get so much easier thanks to tools like Plot, a high-level dataviz library for quick
&
easy charting, and Observable, a reactive dataviz prototyping environment, both from the creator of D3. Through live coding examples we’ll explore how React refs let us delegate DOM manipulation for our data visualizations, and how Observable’s embedding functionality lets us easily repurpose community-built visualizations for our own data
&
use cases. By the end of this talk we’ll know how to get a beautiful, customized, interactive data visualization into our apps with a fraction of the time
&
effort!


React Summit 2023React Summit 2023
24 min
React Concurrency, Explained
React 18! Concurrent features! You might’ve already tried the new APIs like useTransition, or you might’ve just heard of them. But do you know how React 18 achieves the performance wins it brings with itself? In this talk, let’s peek under the hood of React 18’s performance features: - How React 18 lowers the time your page stays frozen (aka TBT) - What exactly happens in the main thread when you run useTransition() - What’s the catch with the improvements (there’s no free cake!), and why Vue.js and Preact straight refused to ship anything similar

Workshops on related topic

React Advanced Conference 2021React Advanced Conference 2021
132 min
Concurrent Rendering Adventures in React 18
Workshop Free
With the release of React 18 we finally get the long awaited concurrent rendering. But how is that going to affect your application? What are the benefits of concurrent rendering in React? What do you need to do to switch to concurrent rendering when you upgrade to React 18? And what if you don’t want or can’t use concurrent rendering yet?
There are some behavior changes you need to be aware of! In this workshop we will cover all of those subjects and more.
Join me with your laptop in this interactive workshop. You will see how easy it is to switch to concurrent rendering in your React application. You will learn all about concurrent rendering, SuspenseList, the startTransition API and more.
React Summit Remote Edition 2021React Summit Remote Edition 2021
177 min
React Hooks Tips Only the Pros Know
Workshop
The addition of the hooks API to React was quite a major change. Before hooks most components had to be class based. Now, with hooks, these are often much simpler functional components. Hooks can be really simple to use. Almost deceptively simple. Because there are still plenty of ways you can mess up with hooks. And it often turns out there are many ways where you can improve your components a better understanding of how each React hook can be used.
You will learn all about the pros and cons of the various hooks. You will learn when to use useState() versus useReducer(). We will look at using useContext() efficiently. You will see when to use useLayoutEffect() and when useEffect() is better.


React Advanced Conference 2021React Advanced Conference 2021
174 min
React, TypeScript, and TDD
Workshop Free
ReactJS is wildly popular and thus wildly supported. TypeScript is increasingly popular, and thus increasingly supported.
The two together? Not as much. Given that they both change quickly, it's hard to find accurate learning materials.
React+TypeScript, with JetBrains IDEs? That three-part combination is the topic of this series. We'll show a little about a lot. Meaning, the key steps to getting productive, in the IDE, for React projects using TypeScript. Along the way we'll show test-driven development and emphasize tips-and-tricks in the IDE.


React Summit 2023React Summit 2023
171 min
React Performance Debugging Masterclass
Workshop Free
Ivan’s first attempts at performance debugging were chaotic. He would see a slow interaction, try a random optimization, see that it didn't help, and keep trying other optimizations until he found the right one (or gave up).
Back then, Ivan didn’t know how to use performance devtools well. He would do a recording in Chrome DevTools or React Profiler, poke around it, try clicking random things, and then close it in frustration a few minutes later. Now, Ivan knows exactly where and what to look for. And in this workshop, Ivan will teach you that too.
Here’s how this is going to work. We’ll take a slow app → debug it (using tools like Chrome DevTools, React Profiler, and why-did-you-render) → pinpoint the bottleneck → and then repeat, several times more. We won’t talk about the solutions (in 90% of the cases, it’s just the ol’ regular useMemo() or memo()). But we’ll talk about everything that comes before – and learn how to analyze any React performance problem, step by step.
(Note: This workshop is best suited for engineers who are already familiar with how useMemo() and memo() work – but want to get better at using the performance tools around React. Also, we’ll be covering interaction performance, not load speed, so you won’t hear a word about Lighthouse 🤐)
React Advanced Conference 2021React Advanced Conference 2021
145 min
Web3 Workshop - Building Your First Dapp
Workshop Free
In this workshop, you'll learn how to build your first full stack dapp on the Ethereum blockchain, reading and writing data to the network, and connecting a front end application to the contract you've deployed. By the end of the workshop, you'll understand how to set up a full stack development environment, run a local node, and interact with any smart contract using React, HardHat, and Ethers.js.


GraphQL Galaxy 2021GraphQL Galaxy 2021
140 min
Build with SvelteKit and GraphQL
Workshop Free
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