Complete Intro to Databases Hasura
Transcript from the "Hasura" Lesson
>> The heavy lifting is done. This stuff's all fun now. I guess it wasn't fun before is the implication of that. I thought it was fun. Even more stuff is fun. Let's talk about graphQL because that's fun. This is too cool for me to not talk about. There's a thing called Hasura that pairs very nicely with Postgres.
[00:00:23] It also has support coming from Mongo and in MySQL, but today it works for Postgres out of the box. So Hasura is a company, they make a product called Hasura that sits in front of your Postgres database, and it turns your whole Postgres database into a graphQL endpoint.
[00:00:45] And it's really cool, and I just wanna show you kind of how to get started. So I want you to come back to your command line, wherever that is, here. So again, we have, yeah, my Postgres running right here. We're gonna run a second container here. And I'm just going to grab it off the website here under Hasura.
[00:01:14] Just run that whole query right there. Not query, but whole command. It's going to connect to your Postgres database again, email@example.com. Yeah, that should work, called my-hasura. I should start a new container here, docker ps, you can see now I have a second one called my-hasura, If this is not working for you, They have a Docker compose file here.
[00:02:00] So I left a link here, just follow this introduction and this will get it running, and it might not get running with your database, you might have to rerun that query that I gave you. But this will get you up and running using Docker compose. It's really easy.
[00:02:13] Again, just follow the instructions. Okay, once you're running, open localhost:8080 and you should end up with, Something that looks a lot like this. This dashboard for Hasura. So Hasura, again, makes your database a graphQL endpoint. A lot of times you can even get around mostly writing any back end code.
[00:02:46] It kind of just turns your database into a back end by itself. So if you're here with me and you have all your data up and running, click on Data. And then you can see you have a, user's board has a boards, comments, rich content. I'm going to click Track, On all of these.
[00:03:13] You can even just click Track All. Now, what's probably not great about these is I made everything public. You don't wanna make your entire database public. I'll let you kind of get into that on your own time, this is not a Hasura workshop. I just wanted to show you that this exists, and it's really cool.
[00:03:31] And I'm also not gonna teach you graphQL. Scott Moss has three courses, I think, on graphQL, and they're all awesome. So if this is interesting to you, take this information, go take Scott's GraphQL courses and come back and have GraphQL superpowers. Okay, but you can write GraphQL queries here.
[00:03:53] So I'm actually just gonna copy and paste one because I can't write GraphQL from memory. So I'll just copy and paste this one into this and click play. And you can get rid of that. Play again. And now, using these GraphQL queries, you can see here I'm getting information out of my database without writing any Postgres whatsoever.
[00:04:17] It's all just running using GraphQL. Now, you compare that with something like maybe Apollo or URQL, yeah, U-R-Q-L, to turn your Hasura back end into powering a front end using this. There's a bunch of stuff like actions, and anyway, Hasura has a bunch of really cool stuff. l just wanted to show you as long as you have a postgres database running, it's really easy to get up and running with Hasura.
[00:04:49] And to be honest with you, I've only really played around with this. I haven't actually made any real apps with this, but I'm impressed with how easy this was to get up and running. We just spent a bunch of time learning Postgres, and in 15 seconds, I had a Hasura backend with just running a Docker container.