Build AWS AppSync API and API Client using Python

   Go back to the Task List

  « 2: Create IAM Roles    4. Create Lambda Function »

3. Configure AppSync API

In this step, you configure AppSync API. You setup the API name and also the model or schema to work with the backend system.

  1. Goto AWS AppSync console, click on the Create API button.

    AWS AppSync

  2. On the next screen, select Build from scratch option and click on the Start button.

    AWS AppSync

  3. On the next screen, type in dojoapi as the API name and click on the Create button.

    AWS AppSync

  4. The API is created in no time. Click on the Edit Schema button to create model / schema to talk to the backend systems.

    AWS AppSync

  5. On the next screen, copy-paste schema in the schema field as shown below and click on the Save Schema button.

    AWS AppSync

    schema {
        query: Query
        mutation: Mutation
    }
    
    type Mutation {
        addTask(id: String!, description: String!): String
    }
    
    type Query {
        getTask(id: String!): String
    }
    
    type Task {
        id: String!
        description: String!
    }
    

    `

  6. The schema is saved. Let’s have a look at the schema which is based on GraphQL specification. It is simple to interpret. The schema has Task data model with two fields id and description - both string type. The getTask method of type Query is used to query the task by id. The getTask method returns string type response. The addTask method of type Mutation is used to add the task. The addTask method also returns string type response.

  7. The schema is ready. But the business logic which implements getTask and addTask methods are not there yet. In next two steps - you create Lambda function which implements these two methods and then attach it back to the schema.