How to build a todo app with Airsequel Enterprise and Elm

In this tutorial we will be building a very simple todo app with Elm’s core library and the github.com/dillonkearns/elm-graphql library. It will load the todos via GraphQL from a SQLite database hosted on Airsequel.
This is what the final app will look like. Not pretty, but functional!
Image without caption
If you find any problems in this tutorial, please feel free to leave a comment!

Setting up the Airsequel Database

Things to know:
  • As the primary key we use the automatically generated rowid column.
💡
The next steps describe how to create the database with the sqlite3 cli tool. You can of course also use one of the many graphical database management apps like e.g. DB Browser for SQLite or Beekeeper Studio.
  1. Create a schema.sql file for creating the SQLite database:
    1. schema.sql
  1. Execute SQL query to create the database:
    1. shell
      sqlite3 todos.sqlite < schema.sql
  1. Go to airsequel.com and upload the todos.sqlite file.
🎉 Your database and the corresponding GraphQL endpoint are now ready!

Creating the Elm app with elm-graphql

  1. Create a new directory for the app:
    1. shell
      mkdir todo-app && cd todo-app
  1. Initialize a new Elm project (press enter on all following prompts):
    1. shell
      npm install elm elm-format npx elm init
  1. Install necessary dependencies:
    1. shell
      elm install \ dillonkearns/elm-graphql \ elm/json \ krisajenkins/remotedata && \ npm install --save-dev @dillonkearns/elm-graphql
  1. Create code for accessing the GraphQL endpoint (Don’t forget to replace the placeholder <db-id> with your database id)!
    1. shell
      npx elm-graphql --skip-elm-format \ https://<name>.airsequel.com/dbs/<db-id>/graphql
  1. Create the main Elm file which will include the code your app: touch src/Main.elm
  1. Copy the file content from github.com/Airsequel/Examples/blob/main/elm-simple-todo-app-enterprise/src/A_List.elm into the src/Main.elm file.
  1. Assign your database id from the previous steps to the dbId variable
  1. Finally run npx elm reactor to start the development server and host your website at localhost:8000/src/Main.elm. 🎉 Our little todo app can now list all our todos including their completion status!
  1. To add also support for writing, updating, and deleting todos you can now replace the Main.elm file with the corresponding files from here github.com/Airsequel/Examples/tree/main/elm-simple-todo-app-enterprise/src.
  1. Finally, feel free to use the code (MIT licensed) as a template for your own CRUD apps.
Happy coding!