Build a GraphQL App with React

Rate this content
Bookmark

In this workshop, we'll build a React app from zero to one using a GraphQL API from Nhost.

Table of contents:
- Sign up to Nhost and create a Nhost app
- Create database table
- Set up React app
- Install Nhost and GraphQL dependencies
- Display data in React app
- Let users sign in
- Add GraphQL API permissions

This workshop has been presented at GraphQL Galaxy 2021, check out the latest edition of this Tech Conference.

FAQ

NHost is a serverless backend for web and mobile apps, providing a database with GraphQL, real-time sync, permissions, file storage, authentication, and serverless functions.

You need to clone the NHost repository from GitHub, install dependencies with npm or yarn, and start the React application.

You can access the Hasura console by copying the admin secret from the Data tab in your application and clicking 'Open Hasura'.

The workshop covers building a React app with GraphQL and TypeScript.

You can create an account by going to app.beta.nls.io and signing in with GitHub.

Yes, there is a free tier available, and you don't need to enter any card details.

You can choose Frankfurt, Germany as the hosting region. Multi-regional support will be added later.

You can create a new table by going to the Data tab in Hasura, selecting the public schema, and adding columns and frequently used columns like ID, created_at, and name.

You enable real-time data sync by using GraphQL subscriptions in your React application.

You can enable third-party sign-in methods like GitHub by configuring OAuth settings in the NHost dashboard and adding the sign-in provider in your React application.

Johan Eliasson
Johan Eliasson
98 min
08 Dec, 2021

Comments

Sign in or register to post your comment.
Video Summary and Transcription
In this Workshop, participants learned how to build a React app with GraphQL and TypeScript using NHost as a serverless backend. They set up the app, explored NHost features, created a Postgres database with a GraphQL API, implemented authentication, and protected the dashboard. Real-time data synchronization was also demonstrated, and participants learned how to enable third-party sign-in methods. Overall, the Workshop covered a range of topics and provided a comprehensive overview of building a full-stack application.

1. Building React App with GraphQL and TypeScript

Short description:

We're gonna start building a React app with GraphQL and TypeScript. To follow along, go to app.beta.io, create an account, and choose Frankfurt, Germany as the location. No card details required. If you have any questions or encountered any issues, please let me know.

And we're gonna start building a React app with GraphQL and TypeScript. So, actually what I will ask everybody who's already joined, so, this is my idea here is do a workshop and you will be able to follow along.

And so, what I will ask you to do is go to let's see if I can get this working. We can go to beta. I'll get the app.beta.io and create an account. Easiest way is just to sign in with GitHub if you want to follow along. So let me make this a little smaller, and so you can just log out and sign up with GitHub, and that should open this view and you should have like a default workspace being created for you.

So you can just click on a workspace and click on new app or click a new app here and create a new app, and we have a free tier, so you don't need to enter any card details or anything. So if you want to follow along this workshop, you go to app.beata.nls.io, create an account, a workspace should be automatically created for you, and you can go ahead and create a new app over here. You can pick a location that's close to you, but you're only allowed to pick Frankfurt in Germany for now. We have multi-regional support coming maybe later this week, so we're going to add a few more data centers, but for now, the illusion of choice, you can choose Frankfurt, Germany.

So I'm just going to ask everybody who just if you have a question... Because I don't see any feedback here. So if you created an account and were successful doing so, just do a thumbs up in the Zoom chat. So I can see some feedback if it's working. Maybe the infrastructure team at NHOS is sweating right now. I don't know. How do I do a thumbs up? Why can't I do it? Yes, we have the Discord in my think. Okay. So I don't see any thumbs up in the chat.

2. Follow Along and Set Up

Short description:

If you just want to follow along and see what I do, that's totally fine. But if you want to follow along, set up in progress. Thumbs up. We've got one. One thumb up. That's nice. So if you just joined, you can go to app.beta.nos.IO. You can see some people are now able to create accounts and create applications. That's perfect. So everybody who just made a thumb up, they were able to create an account here and a new application. And they now have their own Postgres database. They now have a GraphQL API and authentication and storage ready. I'm going to talk to you how you can use that in just a second. Right, I'm not sure how I do do I?

Does it mean you just want to follow along and see what I do or do you have some issues? It's totally fine. If you just want to follow along and see what I do, that's totally fine as well. But if you want to follow along, set up in progress. Thumbs up. We've got one. One thumb up. That's nice.

So if you just joined. Yeah. Totally fine. So if you just joined, you can go to app.beta.nos.IO. I'm going to send the link in the Zoom chat. You can see some people are now able to create accounts and create applications. That's perfect. So everybody who just made a thumb up, they were able to create an account here and a new application. And they now have their own Postgres database. They now have a GraphQL API and authentication and storage ready. I'm going to talk to you how you can use that in just a second. Right, I'm not sure how I do do I?

Okay, so I saw some time up we're good to go. We should be good to go? So, what you can do now is, let's see I have some notes.

QnA

Watch more workshops on topic

React, TypeScript, and TDD
React Advanced 2021React Advanced 2021
174 min
React, TypeScript, and TDD
Top Content
Featured WorkshopFree
Paul Everitt
Paul Everitt
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.
Web3 Workshop - Building Your First Dapp
React Advanced 2021React Advanced 2021
145 min
Web3 Workshop - Building Your First Dapp
Top Content
Featured WorkshopFree
Nader Dabit
Nader Dabit
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.
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
Remix Fundamentals
React Summit 2022React Summit 2022
136 min
Remix Fundamentals
Top Content
Featured WorkshopFree
Kent C. Dodds
Kent C. Dodds
Building modern web applications is riddled with complexity And that's only if you bother to deal with the problems
Tired of wiring up onSubmit to backend APIs and making sure your client-side cache stays up-to-date? Wouldn't it be cool to be able to use the global nature of CSS to your benefit, rather than find tools or conventions to avoid or work around it? And how would you like nested layouts with intelligent and performance optimized data management that just works™?
Remix solves some of these problems, and completely eliminates the rest. You don't even have to think about server cache management or global CSS namespace clashes. It's not that Remix has APIs to avoid these problems, they simply don't exist when you're using Remix. Oh, and you don't need that huge complex graphql client when you're using Remix. They've got you covered. Ready to build faster apps faster?
At the end of this workshop, you'll know how to:- Create Remix Routes- Style Remix applications- Load data in Remix loaders- Mutate data with forms and actions
Vue3: Modern Frontend App Development
Vue.js London Live 2021Vue.js London Live 2021
169 min
Vue3: Modern Frontend App Development
Top Content
Featured WorkshopFree
Mikhail Kuznetsov
Mikhail Kuznetsov
The Vue3 has been released in mid-2020. Besides many improvements and optimizations, the main feature of Vue3 brings is the Composition API – a new way to write and reuse reactive code. Let's learn more about how to use Composition API efficiently.

Besides core Vue3 features we'll explain examples of how to use popular libraries with Vue3.

Table of contents:
- Introduction to Vue3
- Composition API
- Core libraries
- Vue3 ecosystem

Prerequisites:
IDE of choice (Inellij or VSC) installed
Nodejs + NPM
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.

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

Don't Solve Problems, Eliminate Them
React Advanced 2021React Advanced 2021
39 min
Don't Solve Problems, Eliminate Them
Top Content
Kent C. Dodds discusses the concept of problem elimination rather than just problem-solving. He introduces the idea of a problem tree and the importance of avoiding creating solutions prematurely. Kent uses examples like Tesla's electric engine and Remix framework to illustrate the benefits of problem elimination. He emphasizes the value of trade-offs and taking the easier path, as well as the need to constantly re-evaluate and change approaches to eliminate problems.
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.
Jotai Atoms Are Just Functions
React Day Berlin 2022React Day Berlin 2022
22 min
Jotai Atoms Are Just Functions
Top Content
State management in React is a highly discussed topic with many libraries and solutions. Jotai is a new library based on atoms, which represent pieces of state. Atoms in Jotai are used to define state without holding values and can be used for global, semi-global, or local states. Jotai atoms are reusable definitions that are independent from React and can be used without React in an experimental library called Jotajsx.
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.
Debugging JS
React Summit 2023React Summit 2023
24 min
Debugging JS
Top Content
Watch video: Debugging JS
Debugging JavaScript is a crucial skill that is often overlooked in the industry. It is important to understand the problem, reproduce the issue, and identify the root cause. Having a variety of debugging tools and techniques, such as console methods and graphical debuggers, is beneficial. Replay is a time-traveling debugger for JavaScript that allows users to record and inspect bugs. It works with Redux, plain React, and even minified code with the help of source maps.