1×
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.

Autoplay

    Execute Mutations within the AWS AppSync Console

    awsAWS
    graphqlGraphQL
    ^14.0.0
    javascriptJavaScript

    In this lesson, we’ll execute mutations against the new AWS AppSyncGraphQL API, which we created in the last video, and view the data in our database.

    You will see how to create, update, and delete “todos” within the AWS AppSync console

    Code

    Code

    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In
    Discuss

    Discuss

    Transcript

    Transcript

    Instructor: To execute a mutation or a query, click on the queries link in the left-hand menu to open the graphical editor. To view available queries, mutations and subscriptions, we can click on the docs link on the right side of the page.

    To view available mutations, click on mutation. Here, we see three available mutations -- createTodo, updateTodo and deleteTodo. The first mutation we'd like to create is createTodo, so I'll go ahead and define a new mutation called create that will execute createTodo.

    CreateTodo takes an input of type createTodoInput. CreateTodoInput accepts a title and a completed value. From this mutation, we'll return an ID, a title and a completed value. To execute the mutation, click on the orange play button.

    Now that we've successfully executed a mutation, let's open up our data source to view the data in our table. In the table view, we should be able to click on the items tab to view the data in our table.

    Next, let's go ahead and copy the ID of the Todo to our clipboard. The next mutation we'd like to execute is an update. We'll create a mutation called update and execute the update to do a mutation.

    For the input ID, we'll paste in the ID that we copied onto our clipboard from the database. The update to do a mutation will change the completed value from false to true.

    In our data source, we should now see the completed value change from false to true when we refresh. Finally, let's go ahead and create a delete mutation. This mutation will execute the deleteTodo mutation, taking an input with an ID field being the ID that we copy earlier to our clipboard.

    Once we execute this mutation, we should be able to go back to our data source, refresh and see that the item has been deleted.