Skip to the page

Migrating · Platform guides

Coming from Gel

Your schema and EdgeQL carry over. The client, the rules on open types and the schema push process change.

API
—
In the schema
ext::auth::Identity

What you’ll move#

A Gel app: a schema in dbschema, EdgeQL in your code and a server that holds a connection to the instance. The EdgeQL carries over unchanged. The schema gains the line using extension napalm;. Three things change: the app’s connection to the database, access to a type with no rule and the way a schema change is applied.

On GelOn Napalm
createClient() over Gel’s protocol from a serverDeployed queries called by name over HTTPS from anywhere
EdgeQL strings and the query builder in app code.edgeql files with a generated typed call per file
client.transaction(…)One statement per request. Each statement commits whole or not at all
withGlobals(…) set by your serverGlobals read from the caller’s credential
A type with no policy is openA type with no rule is closed
gel migration create and gel migratenapalm schema push, which plans from the schema itself
ext::auth set with configurenapalm sign-in and a client that signs people in
gel dump and gel restoreRows sent through the move’s own statements

Before you start#

You need a project created in the console and the napalm CLI signed in. A project’s address speaks HTTPS and nothing else, so Gel’s client libraries, the gel CLI and SQL cannot connect. Code holding a live database connection does not carry over unchanged. Napalm and Gel lists every difference in one place.

Push your existing schema#

Terminal
# Your schema with using extension napalm; added. The push goes to a branch first.napalm branches create notes rehearsalnapalm schema push notes --branch rehearsal # The statements your app ran, one file eachnapalm queries push notes --branch rehearsal
Napalm’s extension
Every schema declares using extension napalm;. Add the line after the schema’s other using extension lines. A push refuses a schema without the line.
No migration files
napalm schema push compares your .gel files against the branch and plans the change itself. The dbschema/migrations folder is ignored. The questions gel migration create asks, such as a fill expression or a guessed rename, take answers in dbschema/decisions.yaml. At a terminal the push asks the questions and offers to write the file.
Queries are checked
Every push compiles all deployed queries against the new schema in the same transaction and refuses any change that breaks a query.
Outbound calls
Napalm refuses schemas that use std::net. Replace each outbound call with a notify on the type, an action or a job.
Protocol extensions
Protocol extensions such as graphql or edgeql_http cannot listen for requests. auth, ai and pgcrypto work the same as on Gel.

Add rules to every type#

Default-closed access is the first difference you notice. On Gel, a type without an access policy answers everyone. On Napalm, that same type answers no one until a rule grants access.

Closed by default

Unlike Gel’s open-by-default types, a Napalm type returns zero rows until an access rule grants reach.

Declarative schema push

napalm schema push plans directly from .gel files and verifies every deployed query in the same transaction.

dbschema/default.gel
# Open to every caller on Gel. Closed to every caller on Napalm, until a rule says who.type Tag {  required name: str;} # One rule opens it for reading, to people who are signed in.type Tag {  required name: str;   access policy signed_in_can_read    allow select    using (exists global caller);}

Your existing rules keep working after one edit: the project binds the caller straight from the session token, so no server sets an identity global by hand.

dbschema/default.gel
# Before: a global the app's server set on its connection, which the rules trusted.global current_user_id: uuid; # After: who the session's token says is calling. A caller can't send another.global caller := global ext::auth::ClientTokenIdentity;
Closed types
napalm status notes lists every type currently closed to the API. napalm keys reach notes --new counts the rows a key would read, change and delete in each type.
Other globals
A role or tenant your server used to set moves into the endpoint’s serviceGlobals or userGlobals, which the project binds automatically on every matching request.
Your backend
A service key is never an admin bypass. Like any caller, it gets only the access a rule grants its role.

Replace the connection with deployed queries#

Before: a server with a connection
// src/notes.tsimport { createClient } from 'gel' // A connection to the instance, held by a server of yours. The server says who is asking.const client = createClient() export const listNotes = (me: string) =>  client.withGlobals({ current_user_id: me }).query<{ id: string; title: string }>(`select Note { id, title }`) export const addNote = (me: string, title: string) =>  client.transaction(async (tx) => {    const author = await tx.queryRequiredSingle<{ id: string }>(`select Person { id } filter .id = <uuid>$me`, { me })    return tx.queryRequiredSingle<{ id: string }>(      `insert Note { title := <str>$title, author := (select Person filter .id = <uuid>$author) }`,      { title, author: author.id },    )  })

Each statement moves into a file under dbschema/queries, with only the trusted identity changing. The two calls above become the two files below, and the multi-step transaction collapses into one statement.

dbschema/queries/myNotes.edgeql
# The notes the caller owns or was given. The rules decide which: the query doesn't say.select Note { id, title, body, created, is_mine := .owner.identity ?= global caller }order by .created desc
dbschema/queries/addNote.edgeql
# A note of the caller's own. Someone with no person yet has no owner to give it, and it's refused.insert Note {  owner := assert_exists(assert_single((select Person filter .identity ?= global caller))),  title := <str>$title,  body := <str>$body,}
From the browser
Drop the server that only existed to hold the database connection. A page calls the project with the signed-in user’s session, and the rules decide which rows return. Your first app builds that pattern.
Typed calls
napalm generate emits a typed call for each file in place of the query builder or @gel/generate. SDKs covers eight languages.
Transactions
One request executes one statement. A read followed by a dependent write becomes one statement with the read nested inside.
Keeping a server
Your server calls the same deployed queries over HTTPS as the requesting person or with a dedicated service key. A backend service builds that setup.

Move the rows#

Because a dump cannot be restored directly into a project, rows arrive through import statements. The reader pulls rows from the old instance with Gel’s client and passes them to the sender from Switching over.

Statement-driven data transfer

Stream rows from your Gel instance with old policies off and rebuild every link cleanly from old_id.

scripts/from-gel.ts
// scripts/from-gel.tsimport { createClient } from 'gel'import { move } from './send' // The old instance, found the way the Gel client always finds one: GEL_DSN, or the project's own instance. Its// access policies are off for this read: they'd hide every row from a script nobody is signed in to.const old = createClient().withConfig({ apply_access_policies: false }) /** A type's objects in the order of their ids, a thousand at a time. */async function* pages<Row extends { id: string }>(query: string) {  let after = '00000000-0000-0000-0000-000000000000'  for (;;) {    const rows = await old.query<Row>(query, { after })    if (rows.length === 0) return    yield* rows    after = rows[rows.length - 1].id  }} /** Each note as the import statement reads a row: a shape can't give a link's name to a list of ids. */async function* notes() {  const found = pages<{ id: string; owner_id: string; shares: string[]; title: string; body: string }>(`    select Note { id, owner_id := .author.id, shares := array_agg(.shared_with.id), title, body := .body ?? '' }    filter .id > <uuid>$after    order by .id    limit 1000`)  for await (const { shares, ...note } of found) yield { ...note, shared_with: shares }} // People first: a note names its owner. Each comes with the address or the provider account its identity had.await move(  'importPeople',  pages(`    select Person {      id,      name,      email := (select ext::auth::EmailFactor filter .identity = Person.identity limit 1).email,      sign_ins := [.identity.issuer ++ ' ' ++ .identity.subject] if .identity.issuer != 'local' else <array<str>>[],    }    filter .id > <uuid>$after    order by .id    limit 1000`),)await move('importNotes', notes())await old.close()
Terminal
npm install gel tsxGEL_DSN=gel://… NAPALM_URL=https://<project-address>/branches/rehearsal NAPALM_KEY=ndb_… \  npx tsx scripts/from-gel.ts
Old policies off
The reader connects with the old instance’s access policies disabled. With policies left on, an unauthenticated script sees zero rows and copies nothing.
Ids change
Every object receives a new id on Napalm while carrying its original id in old_id. Import statements match on old_id and rebuild links from it.
Identities
ext::auth rows and password hashes remain on the old instance. Each person arrives with an email address or provider account and reclaims every owned row at first sign-in. Moving your users builds the claim, which is why Person.identity becomes optional during the move.

Move sign-in, outbound calls and tools#

Sign-in
Configure the same ext::auth providers with napalm sign-in instead of configure. The client library runs each flow and maintains the session. Sign-in for your app covers every method.
Search
ext::ai indexes work as declared. Because callers cannot invoke ext::ai::search directly, wrap the call in a function in your own module or use POST /search.
Webhooks and jobs
An outbound trigger becomes a notify on the type or a job. notify sends a signed webhook after commit, while a job queues inside the commit itself.
The REPL and the UI
napalm query runs statements under a service key subject to your rules. The console inspects rows, queries and each caller’s reach.

Check the move#

  1. Push to the branch

    The schema applies cleanly, and napalm queries push --branch compiles every statement you moved into a file.

  2. Read a type with no rule

    The type returns zero rows to both people and service keys until you add a rule and push the schema.

  3. Run the reader twice

    Both runs print identical counts matching the old instance with its policies disabled.

  4. Sign in as a moved person

    Their notes appear, and queries that previously took a user id variable now take none.

Type a word or two to search every docs page.