Build and Deploy Instant GraphQL APIs to the edge

Rate this content
Bookmark

Learn how to generate instant GraphQL APIs using a data source connector (GraphQL and non-GraphQL sources), extend and join them both with custom resolvers and deploy to the edge without leaving the code editor.

Jamie Barton
Jamie Barton
67 min
05 Oct, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

GraphBase is a platform that provides a GraphQL API for different data sources. The Workshop covers connecting to APIs, creating a new project, and building a GraphQL backend. It also explores extending APIs, transforming with Open API spec, using database adapters, and securing GraphQL queries. Caching and query scope are discussed, as well as data availability, cost, and authentication configuration.

1. Introduction to GraphBase

Short description:

React-JS for Webinar Thank you very much. Great to be here. Today's world of different APIs that we have. So that's what we are trying to resolve at GraphBase. By default, we put the GraphQL API for all of your different data sources at the edge around the world at over 300 locations. So your user, when they make a request, are most likely going to get a response that comes back in sub 50 milliseconds.

React-JS for Webinar Thank you very much. Great to be here. I think I'm all set up, I was connecting a few displays to help us get going today.

So this first slide I opened up talking about today's world of different APIs that we have. We have so many different SDKs and APIs that honestly, the documentation for all of these varies so much, the player, the developer experience, all of those are very, very different. And these are just a few of the logos I think that for a few of the products that we use today, from databases, to CMSs, to content management systems, to commerce APIs, there is so much. And yeah, we spent so long kind of connecting all of these things and learning the different SDKs and APIs that it's not the best experience. I don't think. And the other thing as well, closely attached to this is that those data sources are often at one region. And if in a very big if, the preventer that you're using gives you the flexibility to push this, push whatever service you've got to different regions around the world, you often have to pay for that flexibility. And the more services you've got and the more regions you want to be in, the more that's going to cost you, and that is not a great place to be in. So that's what we are trying to resolve at GraphBase. Here we are a GraphQL company, and we want to solve this issue. So at a very high level, when you're using something like GraphBase, you get really, really fast response times instead of going back to the different regions. By default, we put the GraphQL API for all of your different data sources at the edge around the world at over 300 locations. So your user, when they make a request, are most likely going to get a response that comes back in sub 50 milliseconds.

2. Connecting to APIs and Creating a New Project

Short description:

In this workshop, we will cover connecting to existing APIs, including GraphQL, OpenAPI, MongoDB, and potentially Postgres. We will also explore deployment options and making queries to different APIs. To begin, we will create a new project using NPX Graphbase Init, providing a project name and selecting TypeScript as the configuration. Once the project is set up, we can focus on the server element and start building our GraphQL backend. The project will include a Graphbase folder and a package JSON file.

So the first thing that I think that I want to cover in today's workshop is connecting to an existing API. If there is any API that you use now, feel free to leave a comment in the chat about whatever APIs that you're using and we can look to connect some of those. Feel free to follow along as I do and use your own APIs. If you want to use the APIs that I use, obviously, they'll be on screen and I can share those in the chat as well.

The first thing that we'll do in the workshop is we'll connect to our data sources and connecting to the different data sources looks a little something like this. This is not in the code just yet, but this is what we'll be doing in a few minutes. We will be using the GraphQL connector. We'll also be using the OpenAPI connector and we'll also be looking very briefly at the MongoDB connector. If we get time, I'll show you the Postgres connector as well that we've got coming out in a few weeks.

Once we've done the connection side of things, we can actually go on to deploy that using the command line or we can connect to GitHub repository and we can deploy this. I think for today's workshop, we can focus mostly on the local environment. I want to show how easy it is to build GraphQL APIs locally without having to deploy. But once you do want to deploy and you want to make this available for your applications, all you need to do is run mpx graph-based dev. It will ask you to log in, obviously, if you haven't done that before. And then yeah, you can deploy it. And what we do under the hood is everything is deployed to the edge and we use the whole thing is written in. Whoops. What's happened there? There we go. So everything is written in Rust, the whole graph-based engines written in Rust. And then we package that up using WebAssembly and we deploy that artifact around the world to, we use Cloudflare, so we deploy it to the Cloudflare network, which is pretty cool. All right. And then lastly, we'll explore making different queries to all of these APIs. Some are GraphQL API, some are MongoDB, and some are REST APIs, believe it or not. There is a tool, pathfinder.dev, that you can use to follow along to make queries. We'll be using the version that's hosted with the CLI, but if you want to use any GraphQL API and perform operations, we have this cool tool. And this is an overview of everything that we'll look at today. So I think we are ready to dive into everything. So if there are any questions, please let me know. But first and foremost, I think we just kick things off. I'm just opening Discord as well, so if anyone does have any questions, please let me know. And please ping me in the chat as well.

Okay, so let's begin by creating a new project. We'll bump the font up here so we can see what's going on. And then here we can use NPX Graphbase Init. Obviously, if you have NPM installed, you'll be able to run this. And then all you need to do is give a name for your project. Now, if you have an existing project, say it's an Astro app, say it's a View app, a React app, an Angular app, whatever kind of application, maybe it's a mobile application with something like one of the mobile frameworks, you can use that. You can use Graphbase inside of that as well. So wherever your project is, if you have something already, change directory into that now inside of the terminal. And then proceed to run NPX Graphbase Init. Because I'm not inside of an existing project today, I'm just creating a GraphQL backend from scratch with outside of a frontend. We're just going to be focused on the server element here. I'm going to give my project a name. So I'm just going to call this TS Workshop. And then what this is then going to do is it's going to ask me what type of configuration would I like to use to scaffold and build and configure my Graphbase backend. I like TypeScript, so I'm going to choose that and it feels very fitting given this is TS Congress. And then once that's done, we will then get a folder with a file in for our configuration. So if we change directory into that TS Workshop now and I'm going to open this up inside of my code editor. If we have a look and see what it's given us, we can see that we have a folder called Graphbase. We have a package JSON, which has some data in here.

Watch more workshops on 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
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
Building GraphQL APIs on top of Ethereum with The Graph
GraphQL Galaxy 2021GraphQL Galaxy 2021
48 min
Building GraphQL APIs on top of Ethereum with The Graph
WorkshopFree
Nader Dabit
Nader Dabit
The Graph is an indexing protocol for querying networks like Ethereum, IPFS, and other blockchains. Anyone can build and publish open APIs, called subgraphs, making data easily accessible.

In this workshop you’ll learn how to build a subgraph that indexes NFT blockchain data from the Foundation smart contract. We’ll deploy the API, and learn how to perform queries to retrieve data using various types of data access patterns, implementing filters and sorting.

By the end of the workshop, you should understand how to build and deploy performant APIs to The Graph to index data from any smart contract deployed to Ethereum.

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!
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.
Batteries Included Reimagined - The Revival of GraphQL Yoga
GraphQL Galaxy 2021GraphQL Galaxy 2021
33 min
Batteries Included Reimagined - The Revival of GraphQL Yoga
The Guild has recently released Envelop - a new, modern GraphQL Server Framework and plugin system. In this talk I’ll share a brief overview of Envelop and why you should probably upgrade your existing GraphQL server to it.
Rock Solid React and GraphQL Apps for People in a Hurry
GraphQL Galaxy 2022GraphQL Galaxy 2022
29 min
Rock Solid React and GraphQL Apps for People in a Hurry
In this talk, we'll look at some of the modern options for building a full-stack React and GraphQL app with strong conventions and how this can be of enormous benefit to you and your team. We'll focus specifically on RedwoodJS, a full stack React framework that is often called 'Ruby on Rails for React'.
Step aside resolvers: a new approach to GraphQL execution
GraphQL Galaxy 2022GraphQL Galaxy 2022
16 min
Step aside resolvers: a new approach to GraphQL execution
Though GraphQL is declarative, resolvers operate field-by-field, layer-by-layer, often resulting in unnecessary work for your business logic even when using techniques such as DataLoader. In this talk, Benjie will introduce his vision for a new general-purpose GraphQL execution strategy whose holistic approach could lead to significant efficiency and scalability gains for all GraphQL APIs.