Drift

Drift is a tool for building a JSON representation of your router (schema) and detecting changes to it.

Generating a schema

To begin, run the following command:

trpc drift
trpc drift

This will output the JSON representation of your router in trpc/schema.json (see an example schema here). Commit this schema to Git.

Detecting changes

When you make changes to your router, run the command again:

trpc drift
trpc drift

If there are any changes, the command will exit with a non-zero exit code, and output a diff of the changes. You can use this to fail your CI pipeline if there are any changes to your router that you haven't explicitly approved.

When you make changes and want to update your schema file, run the command with the -u flag:

trpc drift -u
trpc drift -u