‫So, let's get started
‫with the AppSync service.
‫So, AppSync is going to be used to get a GraphQL API on AWS
‫but this also gets you offline synchronization for data
‫and also real-time updates through WebSockets.
‫Okay, let's create an API, you know different ways
‫of creating the API, we can either use DynamoDB
‫with a wizard with DynomoDB table or start from scratch,
‫but we'll be using a sample project
‫and this one we have different options.
‫We have the EventApp, the ChatApp, the TaskApp,
‫or the BlogApp, okay?
‫And as we can see each
‫of these apps has a different kind of twist.
‫So, this one is very simple.
‫This one uses Cognito User Pools,
‫this one will use AWS Lambda
‫to get data into an Amazon RDS database,
‫and this one will have the real-time WebSockets
‫application in the ChatApp, we'll keep it very, very simple
‫and use the EventApp for now.
‫So, we'll go with the EventApp
‫and I'll call it, My AppSync App, okay?
‫And each template will deploy an API
‫and provision DynamoDB tables
‫and IAM role on your behalf.
‫So, we'll go ahead and create this.
‫And as we can see DynamoDB tables are being created
‫and I just need to wait a little bit.
‫My API is now created and so, we can first look at
‫the source of everything in GraphQL which is the schema.
‫So this is a GraphQL schema
‫and I'm not going to walk you through it
‫but this is to find different types.
‫Such as the comment type, as well as the event type,
‫the event connection, the comment connection,
‫the mutation, and so on.
‫So, these are all needed by GraphQL to function.
‫So, this is the first thing when we create AppSync we need
‫to write this entire GraphQL schema which is
‫about 125 lines long in this example, okay?
‫Next, we define the data sources and these represents
‫the two DynamoDB tables that AppSync has created for us.
‫So, we can click on those
‫and one of these table will be containing the comments.
‫One of them will be connecting the events.
‫So, right now if you go in the tables
‫and look at the items obviously they're going to be empty
‫but we'll see how they get filled up
‫once we get using the API.
‫Next functions we'll just pass over it.
‫Queries is, how we can start using our API,
‫and so this is really cool.
‫So, we'll use a query, and we have different queries here.
‫We can do create events or we can do a listEvents, Okay?
‫So, let's place it on play and say listEvents
‫and as we can see the data is empty
‫'cause we don't have any events just yet.
‫So, let's click again and do a create events,
‫and my first event has been created,
‫this is a very, very simple query.
‫So, you could change the name, the when and the where
‫and the description here.
‫So, if I want to say my second events
‫and then I would run this query against...
‫I'll say create the events
‫then this would create my second event,
‫but now two API queries have been done.
‫So, if we go into a listEvents,
‫we can see that we are returning two different events
‫and if we go into our event table and refresh,
‫we can see the fact that these events
‫have been indeed created.
‫So, this is really cool.
‫The AppSync API directly inserted data into DynamoDB.
‫Then you could go ahead and define other types
‫of mutations for comments and so on,
‫but for now I'll skip over it they're not easy to add in.
‫And this is more advanced GraphQL knowledge,
‫but you get the idea that you could add comments
‫and they would be linked to events
‫and they would fill up this DynamoDB table
‫or the comment table, okay.
‫Next, we have caching.
‫So, you have some caching behavior for reducing the number
‫of queries that you have on your backend.
‫So, that's a full request caching or per-resolver caching.
‫Then for your settings you can configure the API.
‫So, this is my public API that I can share and the API ID
‫as well as the API key people must use to use our API.
‫Then we can share the API name
‫and we can change the default authorization mode.
‫So, right now we're using API keys
‫and we can create multiple ones as well,
‫but it is possible for us to use IAM to have users enrolls
‫or a cross-account access into our AppSync API,
‫openID connect or Amazon Cognito User Pool.
‫If you wanted to connect a user pool
‫that we have already created, for example this one,
‫but I won't go into it too much with the ideas that users
‫or user pool can access your AppSync API.
‫So, I will not save this obviously.
‫Then we can add additional authorization providers
‫which you thought you wanted would allow you again
‫to use one of these security mechanism,
‫logging to send it logs into CloudWatch Logs.
‫Then you have x-ray to have tracing in the extra console
‫and finally tags and then for the monitoring,
‫I'm not going to save this.
‫You could get some metrics information
‫for your API such as the number of errors,
‫the total number of request,
‫there was one request right here
‫and the latency you get for your API.
‫So, all are very, very easy
‫and that's the basics of AppSync.
‫So, that's it.
‫Don't worry too much about the details.
‫This is just a very, very small
‫maybe one question in your exam,
‫and you do know that AppSync is GraphQL,
‫could be WebSockets and could be used
‫to do mobile data offline synchronization
‫and then finally to just delete this, you click on this API
‫and click on delete.
‫So, you have to enter the name of the app to delete it.
‫So, this is how I'm going to do it,
‫but funnily enough if you delete this API,
‫it doesn't delete the DynamoDB tables.
‫So if I refresh this page I'll show you why.
‫So, the DynamoDB tables are not deleted.
‫So, if you don't want to spend some money
‫then you need to delete manually these two DynamoDB tables.
‫This is a bit annoying, but we have to do it.
‫So, we'll delete these two,
‫and this is a cleanup for this hands on.
‫So that's it.
‫I hope you liked it and I will see you in the next lecture.