Skip to content

Latest commit

Β 

History

History
Β 
Β 

workspace-service

Workspace Service

The API is built with Rust, using a web server crate called tide.

How to use

  1. Install the Rust toolchain

  2. Install the SQLx CLI. We use it to run DB migrations and create a cached version of the type-checked SQL queries using the prepare command.

    Note: Until version 0.4 is officially released on crates.io, we use a version from master:

    cargo install --git https://github.com/launchbadge/sqlx --rev 144dcceb445e804b16258d0dd9e580d6a484a01e sqlx-cli
  3. Run the tests to make sure everything is set up correctly: cargo test

  4. Start Docker for Desktop

  5. Run locally: make run-local

After you changed the database schema:

  • Run make prepare to update sqlx-data.json

After you changed the GraphQL schema:

  • Run make graphql-schema.json to update graphql-schema.json

Migrations

To add a new database migration:

  1. Run sqlx migrate add <NAME>, which will create a new file in the migrations folder.
  2. Edit the file and write your migration.
  3. Run make prepare to update the sqlx-data.json file.

Formatting

rustfmt is used for formatting our rust code. CI will fail if code is not formatted correctly.

To run locally: cargo fmt

IDE Support

Most of the team uses Visual Studio Code with the rust-analyser plugin.

The default formatter for .sql files in VS Code is not PostgreSQL-specific and highlights many words that are not keywords in PostgreSQL. It is worthwhile using some PostgreSQL-specific syntax highlighting to avoid confusion (for example, you could install a plugin like this one and run Cmd+Shift+P, Change Language Mode, Configure File Association for '.sql'..., PGSQL).