Build AWS AppSync API and API Client using Python

   Go back to the Task List

  « 5. Configure AppSync Data Source    7: Setup Development Environment »

6. Test AppSync Queries

In this step, you test queries for the AppSync API you have configured. AppSync provides built-in feature to test the queries.

  1. Goto AWS AppSync console, click on the Queries menu in the left. Select Mutation in the explorer and click on the + button. Remove the getTask query method from the explorer using x icon.

    AWS AppSync

  2. It will include addTask mutation method.

    AWS AppSync

  3. Select addTask mutation method and provide values of the parameters - id = 1 and description = my first task. Click on the Run button.

    AWS AppSync

  4. It runs successful and the response from the Lambda function is shown. You can also see a record created in the DynamoDB table.

    Response

    AWS AppSync

    Table Record

    AWS AppSync

  5. Next, select Query in the explorer and click on the + button. Remove the addTask mutation method from the explorer using x icon.

    AWS AppSync

  6. Select getTask mutation method and provide values of the parameters - id = 1. Click on the Run button.

    AWS AppSync

  7. It runs successful and the response from the Lambda function is shown.

    AWS AppSync

  8. Both queries are working well. It is time to write a client which can call the API. But before that we need to make note of few things. In the AppSync console, click on the Settings menu option in the left. Make note of the API URL and the API Key as you need it later when you build the client for the API. For the workshop, you are using API Key for the authentication. But in actual production, you might prefer other methods such as IAM, Amazon Cognito or OpenID Connect.

    AWS AppSync

  9. Great. Let’s setup the environment where the client code is built.