Guides · Shipping & operations
Environments & going live
Develop against your own branch, give every pull request a branch and work through a short list of settings before real people arrive.
- In the schema
- —
What you’ll build#
This page establishes the path from local feature work to production. You develop against a personal branch, each pull request receives an isolated pr-<number> preview branch and merging deploys your schema and query catalog alongside the app before locking down main and monitoring live traffic.
Isolated dev & PR branches
Personal branches and automatic pr-<number> preview branches isolate rows, service keys and sessions from main while testing schema changes against live preview builds.
Checked schema & query push
napalm schema push plans DDL migrations and compiles every .edgeql file in dbschema/queries, refusing any change that would break a deployed query on main.
Map each stage to a branch#
Napalm has no local copy to install. Every stage of an app runs against a real project: a personal branch during development, a branch per pull request during review and main in production. A branch is a separate database on the same project. Each branch starts with main’s schema and sign-in settings but keeps separate rows, keys and sessions.
| Stage | Runs against | Made by |
|---|---|---|
| Your machine | A personal branch | Made byCreated once with napalm branches create |
| A pull request | pr-<number> | Made byThe GitHub App or a CI step |
| Production | main | Made byA merge or napalm schema push from CI |
Develop against a personal branch#
# A branch of your own, with main's schema and sign-in settings. Add --data for its rows too.napalm branches create notes dev-ada # Its API, for your dev servernapalm endpoint notes --branch dev-ada --enable --allow-origin http://localhost:5173 # Push what you're working on to it, as often as you likenapalm schema push notes --branch dev-ada --yesPoint the app at the branch’s address.
# .env.local: the branch's address is the project's, then /branches/<name>VITE_NAPALM_URL=https://<project-address>/branches/dev-adaDeployed queries belong to main, so a branch serves no deployed queries by name. On a branch, the app sends each statement with the call, and a client generated without --deployed works this way. napalm generate notes --lang ts --branch dev-ada checks every query against the branch’s schema during generation. The branch’s passthrough must admit the caller (all for sessions and service keys, or keys for service keys alone).
- People
- A branch signs people in separately and rejects sessions from
main. Sign up on your branch as you would on a new project. - Keys
- Keys also belong to one branch (
napalm keys create notes --branch dev-ada), and a branch refuses any key issued formain. - Handlers in development
- An action’s handler must be reachable from the project. Run the handler on your machine behind a tunnel, and attach it to your branch only.
- Cleanup
napalm branches remove notes dev-adaremoves the branch along with the rows and keys.
Give every pull request a branch#
Install Napalm’s GitHub App from the console, then have the project follow the repository. Each pull request gets a branch named pr-<number> with the pull request’s schema pushed. The pull request also gets one comment that tracks the migration plan and a check that fails when the change would break a deployed query. Merging pushes the schema to main and drops the branch.
napalm repository follow notes acme/notes-app --copy schemanapalm repository show notes--copy data starts each branch with main’s rows as well as the schema. For a preview site per pull request, point the site at that pull request’s branch and allow the site’s origin on the branch. Build the preview with a client generated without --deployed, as above. The branch has the pull request’s schema, and the client sends each query with the call.
# In the workflow that builds a pull request's preview sitenapalm endpoint notes --branch "pr-$PR_NUMBER" --enable --allow-origin "https://pr-$PR_NUMBER.preview.example.com"echo "NAPALM_URL=https://<project-address>/branches/pr-$PR_NUMBER" >> .env.productionWithout the GitHub App, the same setup is three commands in your own workflow. Branches shows the full workflow with the review comment.
Deploy the schema with the app#
If the project follows your repository, a merge deploys the schema automatically. Otherwise, push from CI using a dedicated org token.
# A token for CI alone, which can manage the project. It's shown once: store it as the secret NAPALM_TOKEN.napalm tokens create --label deploy --scope manage --days 30on: push: branches: [main]jobs: schema: runs-on: ubuntu-latest env: NAPALM_TOKEN: ${{ secrets.NAPALM_TOKEN }} steps: - uses: actions/checkout@v4 - run: curl -fsSL https://downloads.napalmdata.com/cli/install.sh | sh && echo "$HOME/.napalm/bin" >> "$GITHUB_PATH" # The schema and every query in dbschema/queries, in one migration. It refuses a change that breaks a query. - run: napalm schema push notes --yesBecause the schema and app deploy seconds apart while existing tabs still run the prior client build, two habits keep rollouts zero-downtime.
- Add first, remove later
- Push an addition (a property, a type or a query) before deploying the app that reads it. Remove an old property, type or query only after nothing calls the old code. Napalm refuses a push that would break a deployed query, so only the app’s own code needs watching.
- A new name for a new shape
- A deployed query is called by name. Changing a query’s variables or result breaks the app still open in someone’s tab. Give the new shape a new name and delete the old query afterward.
Live schema changes applies both habits to a new required property, a rename and an index on a big type. Release rehearsals tries a whole release on a copy of main’s rows first.
Lock down the setup for launch#
The starter setup stays open so the app runs locally in five commands. Lock down the production endpoint and sign-in settings before real users arrive.
# The browser origins that may call the API: yours, and no dev server'snapalm endpoint notes --allow-origin https://app.example.com --remove-origin http://localhost:5173 # Sessions run deployed queries only, and can't read the schemanapalm endpoint notes --passthrough keys --hide-schema # Where sign-in may send people back to, and addresses confirmed through your mail servernapalm sign-in set notes --redirect https://app.example.com/signed-in --require-verificationnapalm sign-in email notes --host smtp.example.com --sender "Notes <sign-in@example.com>" \ --username sign-in@example.com # A ceiling on the month's compute, and a warning before itnapalm orgs limits --cap 500 --alert 300 napalm status notes| Setting | For launch | Why |
|---|---|---|
| Browser origins | Your site’s only | WhyThe API answers browsers only from listed origins. Keep dev server origins off main’s list. |
| Passthrough | keys | WhyA session can then run only deployed queries. A session that sends a custom statement gets 403 deployed_query_required. |
| Schema sharing | Hidden unless used | WhyGET /schema, natural-language questions and the MCP schema tools need schema sharing. Without those features, callers have no reason to read the schema. |
| Redirect addresses | Your site’s only | WhySign-in sends people back only to an address on the list. Each --redirect given replaces the list. |
| Confirmed addresses | On, with a mail server | WhyWithout confirmation, anyone can sign up with someone else’s address. |
| Session length | 14 days, or shorter | WhyHow long a person stays signed in before signing in again. The session token renews every hour, and signing out ends the session at once. |
| Service keys | One per service, with an expiry date | WhyGive each backend a separate key (--label), read-only for read-only backends, for at most 365 days. A key never belongs in a browser or an app. |
| Spend | A cap and an alert | WhyThe cap is the most the org’s machines may cost in a month. The alert warns the org’s managers once the month’s charges pass a lower amount. |
Key and secret renewal replaces a key before it expires. Launch preparation sets the cap, scales the cluster and holds maintenance for launch week.
Watch the project after launch#
napalm status- Every layer of the project with on/off status, missing pieces and the command that fixes each gap.
napalm insights- The slowest queries, the share of each query’s time spent on access rules and helpful indexes.
napalm explain-access- For one object and one person, the rules that allowed access and the rules that refused. Use
napalm explain-accesswhen someone cannot see a row. napalm activity- Changes in the organization and the person behind each change: keys issued, schemas pushed, settings changed.
Production monitoring turns these commands into a routine for each deploy and each day. Troubleshooting & auditing covers three cases: a query that returns nothing, a refused write and a stale read.
Check the production setup#
Break a query on a pull request
Remove a property a deployed query selects and open a pull request. The pull request’s check fails, and the comment names the query. Nothing reaches
main.Call main with a branch’s key
mainrefuses the key. Once passthrough iskeys,mainalso refuses a custom statement sent with a session.Check the project status
napalm status notesshows each layer on with nothing missing, andnapalm endpoint noteslists only your origin.