Skip to main content

Chapter 4

In this chapter, we will create a Query API that provides an overview of tasks. This will allow us to query and retrieve a list of active tasks from the system.

Fourth Usecase: Creating a Query API

  1. Create the Query API Usecase:

    • We will add a querying readmodel named active task. This readmodel will be used to fetch the data for our query.

    Learn About Querying Readmodels

  2. Configure the Query API:

    • Set the Query Result to Many. This indicates that the query will return multiple records.
    • Name the Query get all active tasks. This name will be used to identify and access this query from the API.

    Query Configuration Details

Generate the Code

  1. Set the Usecase Status:

    • Ensure your usecase is set to Ready. This step is necessary for the code generator to recognize that the usecase is complete and ready for code generation.

    Usecase Status Documentation

  2. Generate the Source Code:

    • Verify that your local code generator is running. Generate the source code for the Query API to your machine.

    Code Generation Instructions

Customize the Code

  • No additional custom code is required for this Query API. The code generated will be sufficient for querying the active task readmodel as specified.

Test the Code

  1. Run the Tests:

    • Execute the tests to ensure that the Query API functions correctly and returns the expected results.
    npm run test-integration
    npm run test-unit

Deploy the Code

  1. Configuration & Deployment:

    • Setup your AWS Account and deploy your application to AWS.

    Deployment documentation