Create a database in 30 minutes with GraphQL & AWS AppSync | Morten Barklund | Skillshare

Playback Speed


  • 0.5x
  • 1x (Normal)
  • 1.25x
  • 1.5x
  • 2x

Create a database in 30 minutes with GraphQL & AWS AppSync

teacher avatar Morten Barklund, Full-stack developer and much more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Watch this class and thousands more

Get unlimited access to every class
Taught by industry leaders & working professionals
Topics include illustration, design, photography, and more

Lessons in This Class

12 Lessons (31m)
    • 1. Introduction

      1:33
    • 2. Introduction to GraphQL

      1:43
    • 3. Requirements

      1:10
    • 4. Creating a model

      1:38
    • 5. Testing our work

      4:24
    • 6. Create your own model

      1:29
    • 7. Manually creating models

      4:57
    • 8. Linking models

      4:01
    • 9. Create your own complex database

      4:13
    • 10. Next steps

      2:56
    • 11. Clean up to avoid costs

      2:13
    • 12. Summary

      0:39
  • --
  • Beginner level
  • Intermediate level
  • Advanced level
  • All levels
  • Beg/Int level
  • Int/Adv level

Community Generated

The level is determined by a majority opinion of students who have reviewed this class. The teacher's recommendation is shown until at least 5 student responses are collected.

90

Students

1

Project

About This Class

Do you want to enjoy all the benefits of easy data access in GraphQL without the hassle of creating a complex backend? Then you've come to the right place! This class is for beginners and advanced programmers alike, as this is an introduction to a specific toolset.

This class will teach you all the steps in setting up a simple GraphQL database in AWS AppSync. This includes an introduction to GraphQL in general as well as a brief guide to Using AWS.

Why would you do this? AWS AppSync allows you to feed and manipulate simple data in your web applications without the need for writing complex backends. You simply set up your data sources and access rules in online tooling and you're good to go.

After taking this class you will be able to create simple yet powerful API's with multiple models and complex relations. You will create two databases during the course of this class – and don't worry, it's much more simple than it sounds!

You will be using Insomnia to interact with your backend. This class will cover the necessary introduction to Insomnia as well.

I'm a full-stack developer with over 300 projects behind me and I have been using all sorts of technologies through the years. Feel free to contact me here on Skillshare if you have any questions.

Meet Your Teacher

Teacher Profile Image

Morten Barklund

Full-stack developer and much more

Teacher

Hello, I'm Morten.

I'm a full-stack developer with over 300 projects in my portfolio over the last 15+ years. I have extensive programming experience across a range of web technologies and have trying most things out there.

Feel free to contact me for further information.

See full profile

Class Ratings

Expectations Met?
  • Exceeded!
    0%
  • Yes
    0%
  • Somewhat
    0%
  • Not really
    0%
Reviews Archive

In October 2018, we updated our review system to improve the way we collect feedback. Below are the reviews written before that update.

Why Join Skillshare?

Take award-winning Skillshare Original Classes

Each class has short lessons, hands-on projects

Your membership supports Skillshare teachers

Learn From Anywhere

Take classes on the go with the Skillshare app. Stream or download to watch on the plane, the subway, or wherever you learn best.

Transcripts

1. Introduction: Hi, I'm Morgan. I'm a Web developer with over 300 projects in my portfolio. Over the last seven plus years, I'm here to introduce you to graft UAL and in particular craft drill implemented with Amazon Web services and their service called appsync. With this, we're going to build a movie database, and then you're going to build your own database off whatever content you'd like to organize. You need to be using your computer, not just a mobile device. Yes, you're going to be using some tools that must be downloaded in working both Windows Mac and Linux box. You don't need program experience per se, but knowing how the whip works in general is a good starting place. If not, don't worry and feel free to ask questions in the community. After completing this class, you'll be able to create simple yet powerful AP eyes using Graph Trail and aws appsync. It will not be a production ready. AP. I guess we're not going to cover security speak and other crucial matters, but it will be sufficient for private hobby projects in future classes. We will expand on this knowledge. The class project will ask you to create your own database. It could be a database of your collection of rare Austrian stamps, your favorite sitcom characters or whatever else you'd like to organize while getting an understanding off the concepts presented here. Now let's go on with some important background information. 2. Introduction to GraphQL: to understand graphic you will when he'd treated juice on a P I or an application programming interface. First on a p, I is signified the protocol by which to piece of software talk to each other. Web services are special type of a P I in that they were over the Web. In general, a Web service allows the client to talk to a server. The client can, in this case, be a browser on application or even other Web service. The classic Way of building Web AP I is by creating methods for all the different things your client needs to do. A Web service might have a method for creating uses. Method for updating uses one for listing use and another for sure in the use of page. All these requests require independent custom coding. This is where craft fuel comes in with graphic. You will you create a single service that knows about all the different types of objects in the application and all their relations to generate requests that pitch or manipulate data in a structure language, the graft real server, then make sure to get the correct resource is verifies that you have access Maybe there's some manipulations and return to your data. Graphic ul is a way of accessing your data in a safe way across the wet. There are two types of requests in the graft. You'll lingo. Actually, that goes for any Web service, but in graft, you'll to use these to turn specifically, you do a query or a mutation. A query fetches data and mutation generally either creates updates or deletes data. Now let's continue to some necessary requirements. 3. Requirements: to follow along with this class, you need to have a user on Amazon Web services. If you already have an Amazon account, you can use that same account. You will even use the same credit card. If not, you need to create a user and input a credit card. Information. Simply go to aws dot amazon dot com, and either locking or create a user. Don't wear too much about the credit card. First of all, you're built by usage, and the total usage of this experiment will amount to no more than a few cents if even that . But AWS also has a free tier for your first year of usage, and they will cover these experience by a large margin. Just remember to deactivate all the resource is that you have created to avoid future costs . Secondly, you need to install in some. Yet it's a free and open source tools for testing FBI's, including graft girl, go to insomnia dot rest, install the software and make sure it runs. It should look something like this. Feel free to uninstall once you're done with this class. After this, we'll dive right in and create our very first graph to L. A P. I 4. Creating a model: our first FBI is going to be a single model. AP I. It's a list of movies and reach movie will at the title and year of publication. We'll create this using AWS EP Sinks wizard for creating a new A P I. First make sure you're locked into the AWS console from here. Search navigate to AWS appsync. If you don't have any FBI's already, it will look like this. Not pressed the button to create a new A P I. And then just press start. This is already said to create with, with it input the bottle name movie. Next up, other fields of this model You should always have an I. D field. It's used for internal referencing the Wizard by default, or just that we have a title field, so let's keep that we had a new field. Call it year and leave the rest, as is now. Press create and give the A P I a name, for instance, favorite movies and then proceed. We're now sent to the FBI query page. It might look a bit confusing bright, nor this page for now, 80 over us. Absent has Osmani created a scheme that based on the information we've provided using the menu to the left you can navigate in your new a P I. If you go to this keeper, you'll see information that looks like a lot of the information we gave. Wouldn't created the model, but with some extra stuff at it. Remember this AP eyes alive. Now, if you know the correct your ill and the correct secret a p I key, you can access it. But of course, nobody knows this yet. Next, we're going to find this information and use it to test on you a p I. 5. Testing our work: in this lesson, we're going to test our FBI. First thing we're going to do is create a new request by present command or control. And that's called this request movie create because the first thing we're going to do is create a movie in our database in the little drop down next to body. Change it to graft drill in report on era because it's not a problem graft your career yet , but we'll fix that later. Now go to the Settings page in 80 years. Council for your a P I under a P I details couple Ural and pasted in the hitter off the request in insomnia. Secondly, company. Maybe I key in the third bucks from the FBI Details Page and insomnia goes to the head. It's half at a new hitter. Call it X, a p I key or lower case and paste in the value. It you look something like this. Let's go back to the graft. Real Tap is still displays a warning about unknown schema. We can fix this by going to the small schema menu and selecting refresh schema now in some years should be able to fix the schemer correctly. If it's still reports an error, make sure that you use the correct Uriel in the top and that you used to correct head of name and value as well. Now things get a little hairy in the graft yields happy we're going to write our query, which is actually a mutation. The Sensex is a bit special and for now, just write it as is, and later you'll better understand why you're writing it in this way. First, we're going to create a mutation and give them in. Let's just call it in, then in brackets. We're going to use the name off the mutation we're going to call here. Insomnia will help you with completion. If you start typing, create able corrected. So just create movie in parenthesis. We're going to add the input for this function. This has to be structures as Jason and the Syntex is. As you can see here, we're providing an input object that has a title and a year each set to the correct values . Finally, we're going to tell the graft you'll server what information we want back when the mutation is completed. Here, we're going to ask for I D title in year again. In some, you will help us with completion. All that is left is to send the request press command or control, enter or use the send button in the top. If there isn't era in the syntax, the so will respond with an error object. It can be a little difficult sometimes to correctly understand what you need to change to make it behave correctly. So just make sure you've read everything exactly as I have done here. When the cold succeeds, you will get back the requested information about the new movie object. The idea is also generated by the server, and the title this year is as we have created them. In order to see that this new movie object actually is in our database, we go to create a new request asking for a list of old movies in the database. Do that by duplicating the old request and renaming it to move a list. The euro and hitters are the same. We just need to clear the graft you will request and write a new one. This time we're making a query. Let's call it Q. And it's for list movies as suggested by the completion based on our schemer, then in brackets. As for all the items in the list and for each item s for the necessary information, let's just go with all of it and asked for I d title and year. Send the request and see the hopefully correct response. You get back a list of one item, which is our previously created movie. Now let's add another movie by going back to the movie, create request, change the input parameters and invoked the request again. We now see a new movie has been created with a new I. D. Then try to list all the movies, simply sent the same move. Willis request again. This time we have two movies in the list. We now have a working A P I. If you want to experiment with the update, movie and elite movie requests feel free to do so. The easiest way is to duplicate the movie, create request and change the parameters as needed. In some years, completion should help you with all the parameters. Ah, small hint to update or delete an object, you need to reference the I d offset object 6. Create your own model: Now you're going to create your own e p I using these same steps, but with your object. When you go back to the appsync page, it looks a little different now that you have a Navy I. But just press the create button to create a new one and use the Wizard once again. Then create a model of something you'd like to organize. Maybe a collection of your pets or your favorite Scandinavian furniture. Design us. Make sure to create some fields in your model and maybe you some different types. After that, try to call you a P I insomnia. First, create a new object, then try to list your objects using these exact same steps that we use previously. Remember to cover the your ill and insert a new hitter with the correct name and value, and change the body type to graft you will. Your deliverable for this part of the class project would be to take a screenshot of insomnia, showing your list of objects in your database. Here is my example. First, I created this superhero model with name and a Boolean value that can only be true or false about whether the superhero wears a cape. Then I invoke my FBI from insomnia. You can see in the response to the right that I have two items in my database. Superman and Arm. Fall off boy and only Superman wears a cape. Go ahead. Try to complete this part of the class project. Now, before we continue. If you have any questions, feel free to post them in community section and please provide screenshots of what you've tried. Next, we're going to create a slightly more complex AP I with multiple models. 7. Manually creating models: in this lesson, we go to create some models manually that is not using the Wizard. We're going to do this by describing our models in the graph Curole structure. Language is very simple, so don't worry too much about it. We go to create two models, and at first they're more or less unconnected. Before we go into creating these models, however, its first gets them out on paper in data signs. This would be called creating an entity relationship model, but we're just going to draw some boxes and put some names on them and highlight their relationships. This is my nice diagram off the molds records use for this except that movie model with a title in a year as before. But we also have a Shangri Model with the name Field. Shanghai's can be things like thriller or comedy. Remember that both of these models will have internal I D as well to reference the objects . There is a relation between these two objects, which is an arrow pointing from the movie to the shower. This should be read as every movie house one Shangla that is every move we can belong to. One and only one shower. This might not reflect real world scenarios, but in our example, that's how we're going to do it in reverse. This relation also reached us. Every Shankar has a list of movies that is the movies that have this show as their shower. In order to describe this relationship in the models Mirjana feel to the movie model called Shangri I D, which is a reference to the idea of the shower that the movie belongs to. Here you see the model diagram with this new Sean Raidi field at it. Note that it's all in one word. All lower case. Let's create a new A P I. This time without using the Wizard, Go to the front page for appsync listing your existing AP eyes. Collect the bodies create a new one in select built from scratch. This time we'll send you name it movie database. Now we haven't empty AP. I that's at a model to it. Go to the schema and select Create Resource is from here will define a new type. The first type would be on you movie model. First, change the type names and movie, then remove the three D four fields we're not going to use then at a new line for the year , said to a stream and another lying for the Shang Raidi all lower case said to the type I d the exclamation mark after the string next to the title The notes that this field is required. Let's just leave that for now, us. We're not bothering with input, validation or air handling. Yet below this, you will see some information about this new table that were created. We have to use this section this time around. First of all, if we just leave, leave the table name as movie table. It'll complaint that we already have a table with that name, So let's change the name to movie table of Me too. Secondly, we're going to have to look up movies by Shannara i D. And that can only be done by creating an index. This index is an internal look up table that will allow the underlying database to find all objects with acumen value. So let at let's add on index, the name should be Xiang Righty index and primary key must be set to shine. Rieti. It's a bit complex, but it's a necessary step further below, you'll see some extra schema unrelated things that would be auto generated for us, including the graph Creole structure needed to create Update, Delete and Fitch in this new type. Just roll past that and press create after prison Create bill Work appeared in the background, and our model will be edit your FBI. Now we repeat the steps for our Shangri Model. Create Resource is change the type name to genre. Remove all the fields besides I D and add a new field name with Type Street. Please note that we're not in any way adding anything to describe that A Shamus has movies related to it. The relations only stored in the other direction to phantom movies of a Shannara. We don't look in the Shanghai table at all. We only need to look in the movie table. Let's change the name off the underlying table to Shangri Table V two for consistency. We don't need any extra indexes on this table. After reports create this new model and all related graft, you'll structure will be added to esquina. Now let's create the call in insomnia to create and this genres as well, creating a list movies. I have cheated a bit and already created them here. Remember that? Do you ill? And the A P I. K is the same for all these requests. The group that hearing insomnia I have prefix the names with me, too. First we create a Sean were thriller. Then we cover the idea of this new shop where we needed to create movies in this genre. Then we create a new movie which belongs to this younger Let's at Saigo from 1960 remember to insert the correct Shandra i D. If we now list on movies, we'll see one movie and it has a Shangri I d. We can, however, not see the name off the Shannara, only the I D. That's not very useful. Let's fix that in the next lesson. 8. Linking models: when we listed the movies in the previous example, we just got a shocker. I d for the movie, but no information about the object. Let's fix that. Instead of having a Sean righty for movie that's have a Shangla, which is an object with extra information. Let's get back to a schema. Scroll down in the scheme until you find the definition for the movie type, remove the Shang Righty Field and Instant and a new Shangri Field of type genre. Remember to save the schema, going back to insomnia and the V two movie list action. We cannot refresh the schema. The Shower I D attribute is now reported as an era. This change. It's a genre and ask for the genre feels, idea and name and run the request. It works, but the Shangri Empty we haven't actually told absent how to fill this value. Switching to absent, we will now add a result for this new attributes next to the scheme and resolve us. Scroll down to the movie type and attention New resolver. To resolve this attribute, we have to look in the shower table, so select that from a drop down Now we have some new Syntex. There's this not graft religion, sex. This is Amazon, Epson, Sensex and their internal programming language for hooking up these resolve us. The syntax is pretty complicated because you can do a lot of things for this purpose. We're going to use the default resolve us as could be seen in the drop down in the right corner. Get item by i d. We're going to look for a nightie that matches the source dot shankar i d. This might look a bit magic, but this is how you do it. Say the resolver Go back to and Sami and try the list movies request again. This time it comes back with a proper Shangla for our movie. Okay, now we want at the reverse. That is, when we ask for your Shandra. We want to be able to ask for the movies belonging to that sham. Rest Well, To do this, we go back to the schema, find the Shannara model and add a new field named Movies Off the type Movie Connection Movie Connection is an automatically created type that is essentially a list of movies. If we do nothing else and go back to insomnia and refresh the schemer. We can now in RV to Shangla, list at movies to our decide response for the movies. We need to list the items, and for each item we need the I D title and year. By running this query, we get an empty list of movies for our Shannara, as we haven't yet entered the resolver. Now a scheme will now scroll to attach a resolver for the movies field for a shocker. This time our data source will, of course, be our movie table. But now we're not going to search for a single item by I. D. Is that we're going to make a simple query by selecting this from the top right? Drop down for the query expression refers Need to specify it that we're using an index named Shankar I. D. Index. We're going to look for movies with a given Shangla I. D. And this idea should be resold from the source dot i D, which is a reference to the i. D. Off the current Shannara again is a very superficial introduction to the complex language offer solvers. But just trust that it works If we save this resolver and go back to insomnia. You will now see that our list of Shangri, as for each younger, also has a list of movies for that sham. Er, But wait this more We can do this recursive Lee, because, as we know from earlier, every movie has a Shangla so we can ask for the Shannara off every movie off a Shannara. And we can even ask for the movies off a shangla of a movie off a Shannara. It's silly, but it will begin to demonstrate power off graft girl, For instance, Imagine that we had a movie page displaying movie as well as other movies off the same Shangla. We could then make a query that asked for a specific movie for the Shangri Off the movie and then for old movies off that shamrock or in a single request. Okay, that's enough of me showing you how to do things next up. You're going to create your own complex database 9. Create your own complex database: in this lesson, you will create your own database. The deliverables will be part of your class. Project is a photo of your model diagram as well as some screenshots of your FBI in action . First up, you need to think of something to organize something with two or three types of objects in relation to each other. Take a picture of your model diagram and uplifted to the glass project. Secondly, you will have to create your A P I in aws appsync. And finally you will call this a P I from insomnia. Your last deliverable will be to document your A P I in action with some screenshots, often Sonia, display your queries and responses. Imagine you want to create a database of celebrity dogs. For this, you could create a to model diagram like this. It has a dog table and each dog and name and an H, and it has a table with a name off the green. And finally, it has a relation from adult to the breed that is. Each talk has the 2nd 1 breed, but there could be many dogs with the same breed. This would require you to add a breed 18 to your talk table. You can also be a little bit more ambitious and create a three model data piece. For instance, you can create a database of books where each book has an author and each author as a country of origin that would look something like this. Feel free to post the video to inspect the different models and their fields. You can also organize three models in a different way. Take this example. Here we have a database of music albums. Each album has been performed by Given Artist, and each album has also been published by a specific label. This would require us to add fields for both artists i D and label I d to the album table. Feel free to ask questions about how to best model in your database in the community section and remember to not make things too complex. This is only for testing purposes, and to understand how AWS appsync works, remember to upload a picture of your model diagram to your class project. The next step is to implement your models in appsync, create a new FBI from scratch, give it a name to stop adding your models from the schema page remember to create in Texas for all the ideas that reference ideas of other tables trying to test this in insomnia even before adding the relations and resolve us, all of these things should work correctly. Orbit BP it boring without the relations, then you should at the proper relations and resolve this. Given our music album from Earlier, we would need to change the artist i d Field on the album Type two artist and, as a result, to look up the artists in the correct table. Likewise, for label I D. After that, we will do the Reverse and Adam Albums Field to the artist model. And as a result for this looking up albums by artist I D remember to use the correct artist I D. Index. Likewise, for the open field on the label type. This time, looking up albums by label I D. Using the label I D Index finally makes you to test all aspects of your FBI. Remember to test more complex in nested queries. Look at this as an example. Based on the previous music album database diagram, this is a query that retrieves a single artist and then retrieves all the albums created by this artist and for each album retrieves the label off this album. As you can see in the result, the Beatles is listed with three albums in this database too often published by the same label but the 3rd 1 by a different label. As a final deliverable for your class project. Take a screen shot off the most complex and yet nontrivial query in your database, showing the relations and models working together just like the one we just saw. After you're done with this class, you can, of course, keep working on your database, adding more models and more complex relations and resolve us as well as trying other ways to create your database. Well, briefly, look at some of those options in the next lesson. 10. Next steps: even though we've looked at many things in this class, we've only just scratched the surface of graphical end of AWS. Absent. You can do a lot of other things with both of these technologies, some of them you could even try out with the A P I that you have already created as a class project right now. Imagine, for instance, that you have thousands of movies in your movie database. You're never going to display all of them, so why would you ever load often? Instead, you'll probably display a substance in one of two ways. Either you display a search result or filtering display only those from a given year or given Shandra. Or you're going to use Patty Nation to only display 20 or 50 movies at a time, with links to go to the next page of results. You might even combine those approaches. Actually, you can already do this in your A P. I appsync as automatically created ways for you to filter and Petty Nate A list result. Feel free to tired out, as in this screenshot the triggers to add parameters to the list movies Query. Remember that you can use insomnia is built in completion to get a hint of what you can write. Another scenario might be a more complex database. If we were to add access to a movie database, we could not stick with the same type of relation every act second being ordered. One movie and every movie most likely has more than one actor. This is a many to many relationship, and it's more complex to model. A common database approaches to Adam Intermediate Model, for example, a role, a role that has exactly one actor and one movie as feels. You will find all the access of a movie by listing all the rules in the movie and each role listing the actor can also make this more complex by adding other types of resource is that aren't just simple tables. Resource is can, for instance, be other AP eyes. You could ask your graph killed a P I for all instagram posts of a given user and then absent would invoke the instagram a P I to get the information before sending the combined response back to you all the A p I is that we have created so far open toe all uses If anyone had access to the A P I, they could delete all the items on all day, and it would be lost in the real world. You would set up some sort of authentication in front of your database, so only registered users can manipulate the data. And then you would add authorisation rules to the different fields and methods to only allow certain uses to do things. For instance, everybody might be able to see information about a movie, but only the user that created the movie is allowed to edit and delete it in a future class we're going to look into exactly this topic 80 years has a serious called cognito that allows users to log in, allows the software to validate that only the right users allowed to access and or manipulate the different resource is 11. Clean up to avoid costs: before ending this class I feel applies to tell you about how to clean up after yourself. First of all, because it's always a good of you to know how to revert something. You do it, but also because if not small costs might incur on your AWS account. But most likely not at all, or my experiments leading up to this class have summed up to exactly syrah $0.0. I have not spent a cent on this, and I'm not even on the free tea or anymore. The first thing you can do is remove your AP eyes. It's very simple. Simply select your FBI from the Epsom front page and delete it. You would have to confirm the lesion by retyping the A P I name. Repeat this for all the FBI. So you want to remove the leading the AP ice will have. You're not deleting. Underlying resource is that you have created the table still exists in the background. To delete these, find the service name dynamo could be in AWS. You can do this from the service. Drop down in the header here, select tables in the left menu. This will display all the tables that you have created in Dynamodb. If you're using your account for other things than these experiments, be very careful about what you delete. There's no getting things back. If you delete something important without having a back up here, you see all the tapers I have created to implement all the examples in this class. To delete them, simply select each one and press delete. In the dialog that appears, Just need the first option ticked. If you want a bag up off your data, you can also take the second option before proceeding. If you delete the tables, your A P I will no longer function, so it's a good idea to only the league tables off already removed. AP Ice If you want to completely delete your AWS account, you can do that, too. In the header, click your name and selecting my account from the drop down. If you scroll down all the way to the bottom off the next page, this apartment ST Close Account president and follow the steps. You can also safe and removed the install software insomnia. To do this, simply follow the uninstall procedure that you can find in the help section off insomnia, but I'm installed similarly to other programs on your system 12. Summary: that's it. You completed all the lessons of this class and hopefully you've been playing along on the site By completing and uploading your class project, be sure to follow me as a teacher here on skill share to get updates on future classes. Expanding on what we've built so far as mentioned, there are many other relevant topics that we will dive into in future lessons. Thank you so much for watching. I truly hope you enjoyed it. And I hope you will leave a review of this class your feet back. It's the only way I can improve as a teacher, so feel more than free to be honest and forthright with constructive criticism. Thanks again and have fun.