Skip to Content
API ReferenceSchema Publishing

Schema Publishing

The Foir GraphQL schema served by the public API is versioned. Editing a model, operation, context dimension, auth provider or any other definition in the console puts the change into a draft state: public API consumers continue to see the previously published schema until a release carries it.

This protects production traffic from breaking the moment a schema-shaping change is saved. You stage your schema and content changes together, then release them in one step when both sides are ready.

How it works

Every schema-surface entity carries two states:

  • Draft — the live state in the console. Edits land here immediately.
  • Published — the state served to your app’s keys.

The two move independently. Saving a draft in the console does not change the published state; a release does.

Channels

Public API requests choose between the two states via the X-Foir-Schema-Channel header:

ChannelDefault forHeader
PublishedEvery caller without the header, and a publishable or a server key without drafts:read that sends it(omit, or published)
DraftThe console; foir commands run with --draft; a key holding the drafts:read scope, which is a preview environment’s own keyX-Foir-Schema-Channel: draft

A publishable or a server key without drafts:read cannot opt into the draft channel: the header is silently ignored and the published schema is served. An admin key without the drafts:read scope receives a 403 if it requests draft.

# Production: served the published schema curl -X POST https://api.foir.dev/graphql \ -H "x-api-key: foir_pub_..." \ -d '{"query": "{ pages { id title } }"}' # Staging preview: its own publishable key, holding drafts:read, served the draft schema curl -X POST https://api.foir.dev/graphql \ -H "x-api-key: foir_pub_..." \ -H "X-Foir-Schema-Channel: draft" \ -d '{"query": "{ pages { id title subtitle } }"}'

The draft response is stamped with Cache-Control: no-store so CDNs don’t cache an in-flight schema.

What gets versioned

The publish lifecycle covers everything that shapes the public GraphQL surface:

  • Models: type names, field shapes, and configuration (the owner plane, default visibility, singleton, versioning, publishing, variants, lookups and embeddings)
  • Operations — custom mutation signatures, input/output schemas, async lifecycle
  • Context dimensions — variant resolution inputs
  • Auth providers — login mutations exposed in the schema
  • Hooks: which events fire which operation, with what filter, and whether the hook is active
  • Cron schedules: the cron, the timezone and the operation a schedule runs
  • Sign-in and sign-up: which auth providers the hosted sign-in offers and how each is configured, what an auth client may redirect to and ask for, what each role grants, and the project’s signup mode, sign-in methods, user signup, staffing and session windows
  • Branding and email: the project’s branding and addresses, its sender and reply-to, and the copy of every email it sends
  • Locales, the variant catalog and context dimensions: which locales content resolves and falls back through, and the rules segment and variant evaluation reads
  • Notification categories: the NotificationCategory enum the public API validates a send against, and what each channel does for a recipient who has set no preference of their own
  • Apps and placements: an installed app’s settings and mappings, and the console placements it adds

Everything a user signs in, signs up or is mailed through is served the published copy too. Turning a provider off or closing sign-up in a push leaves the login button and the signup form as they were released until the release, and a draft request (a console preview) sees the change at once. To close sign-up in a hurry, push the change and release it in the same step: foir push --publish, or save it in the console and release it from the unpublished list on the home page. A new provider, role, auth client or locale waits for the release as well. Deleting one, or disabling an auth client or a role, takes effect at once.

Credentials are never part of a release. An auth provider’s client secret, a key a vault reference names and an API key’s scopes change the moment they are written, so a rotation is live at once. A client id and a client secret that change together are therefore best rotated in one release: the secret is live at once and the client id only at the release.

An email a request causes is written from the copy that request was served: a mail a published request sends uses the released sender and copy, and one a console preview sends uses the draft. A mail no request caused uses the released copy.

An operation’s published copy is also what production runs: the endpoint and timeout a call is dispatched to, the permissions, precondition and second factor that gate it, its quotas, and its retry and callback policy. Changing any of them in a push or in the console leaves production on the published copy until the release, while a request on the draft channel is dispatched with the draft. Work a request causes later (a hook delivery, an execution’s retries) runs on the copy that request was served, and a cron schedule always fires its published copy. A schedule’s pause and resume are the exception: they take effect at once, because pausing is how you stop a schedule in a hurry.

A model’s configuration governs record writes as well as the schema. A write is held to the configuration of the channel it is served: a storefront on the published channel keeps writing under the published owner plane, singleton rule and default visibility until the change is published, while the console, which works on the draft, is held to the new configuration at once. Publishing is what moves the model’s existing records into the new shape: versioned, with variants, and with the visibility they inherit. A model with no published copy, one you have unpublished, accepts writes on the draft channel only.

Record content has its own per-record draft/publish flow, controlled by the preview: true query argument, separate from this lifecycle.

  1. Edit in the console. Add fields, rename, change configuration. Save the draft.
  2. Update your application. Bump types, write content, deploy your code.
  3. Preview from staging. Point your staging deployment at the production API with its own publishable key holding drafts:read, and send X-Foir-Schema-Channel: draft. Verify your queries succeed against the new schema.
  4. Release. When staging looks good, release the drafts from the unpublished list on the home page, or with foir release publish. The public schema flips for every consumer within seconds.

A release that carries a breaking change (a rename, a removed field, a narrowed type) or one to review shows the diff of exactly what it carries before it goes out. Additive changes (new optional fields, new types) are safe to release at any time.

Configuration changes are in the diff too. Moving a model onto an owned plane (user or organization) is breaking: from the release on, a record that names no owner of that kind is refused, and the diff counts the records that name none today, at every level of the project, which the release leaves owned by nobody. Turning versioning, publishing or variants off is breaking while the model holds records; turning them on, or changing the lookups or the default visibility, is flagged for review.

Releases

A release stamps drafts into what production serves, in one transaction, so the schema flips coherently rather than definition by definition. It carries the pending drafts at your level, or the ones you name, of any family: models, operations, hooks, schedules, auth providers, roles, auth clients, locales, the variant catalog, email copy, notification categories, design tokens and the project’s settings. A release refuses as a whole: if any draft it carries cannot be stamped, none is.

A release that names nothing carries the drafts you are shown and may release: a family takes its own write to release and its own read to be shown. What it leaves is said in its answer. The drafts you are shown and may not release are named, and where something waits in a family you are not shown, the answer says that something else is waiting and names nothing of it. A release that names its items is charged each family it names, and is refused if you lack one.

  • From the console. The unpublished list on the home page is the release. Publish all releases everything pending; ticking rows and Publish releases those; Schedule releases the selection, or everything pending, at a time you pick. A definition’s own page links there while it has changes waiting.
  • From the CLI. foir release status lists what a release would carry and what it would leave; foir release publish releases what you may, or the family:key items you name (foir release publish model:article operation:checkout); --at schedules it; foir release cancel withdraws a scheduled one; foir release list shows the history.
  • From an agent. foir_get_project_publish_status, foir_publish_release, foir_cancel_scheduled_release and foir_list_releases.

Each release is recorded: who made it, when, and the published copies it replaced. Rolling back the last release (the home page’s Roll back, or foir release rollback <id>) republishes exactly that set, an operation’s endpoint included, and is itself a release, so it can be rolled back in turn. A rollback refuses a definition released again since, since putting it back would undo the later release rather than this one.

A scheduled release is carried out when it comes due by the same verb, under the level and the person that scheduled it. It asks again whether the workspace and the organization it belongs to may still change production then: a release scheduled before a workspace lapsed, or an organization was suspended, is refused and recorded as failed rather than carried out.

Each family a release moves is charged the authority that governs it, so a person or key allowed to change models releases models and nothing else.

A release can carry record versions as well, by id, and goes out at a time like any other: its definitions first, all or nothing, then each record version with its own outcome. A refused release puts out none of its record versions.

Deleting a released definition

Deleting a definition production is served waits for a release, whether you delete it in the console, with a family’s CLI command, through an agent tool or the API, by leaving it out of a foir push, or with foir remove. The definition leaves the draft at once; production keeps serving its published copy until the release that carries the deletion removes it (a model’s records go with it then). The pending list shows it as a pending deletion; Keep in the console, or foir release keep family:key, takes it back, and so does editing it or declaring it again in a push. A definition that was never released has nothing in production to keep, and is deleted at once. A release that carried out a deletion cannot be rolled back: republishing a copy cannot bring back a row that is gone.

Removing a config holds the deletion of everything it declared that production is served, and the config stays, out of every list, until the release that carries the last of those deletions; pushing it again brings it back.

Standing in an organization, a release carries that organization’s own drafts: its models, operations, hooks, locales, design tokens and the rest, never the project’s or another organization’s.

Newly created entities

A brand-new model or operation is released as it is created: nothing writes to the model or calls the operation yet, so adding the GraphQL type or mutation can’t break any existing query. Subsequent edits stay in draft until a release carries them.

Nothing else is. A hook would fire on events that are already flowing, a schedule would start running, a new auth provider would put a button on the hosted sign-in, a new role or auth client would change what a user is granted or signed in through, a new context dimension, locale or catalog entry would change what content resolves, and a new notification category would change what a send may name. Each waits for its release.

When you provision via config-as-code, a plain foir push also releases, in the push’s own transaction, a model update that only adds optional fields, and records it as a release. Everything else it writes waits for a release, and the push says which is which. foir push --publish releases everything the manifest declares. See Push and Remove.

Unpublishing

Unpublish withdraws a model, operation, auth provider, context dimension or the design tokens from production at once, as a release of its own: it is listed in the release history with the published copy it removed, and rolling that release back restores it. Any client query that selected the type starts failing on the next schema rebuild.

A withdrawn definition stays withdrawn. Publish all, a release of every pending draft (scheduled or not), and foir push --publish leave it out and say so; editing its draft does not bring it back. It comes back when a release names it (the console’s Publish beside it, or foir release publish family:key), or when its withdrawal is rolled back. Use it deliberately, for entities you’re retiring, not for transient configuration changes.

Failure modes

  • Public-key client calls a field that doesn’t exist on the published schema. The query is rejected at validation time. To get this field for that consumer, release the change.
  • User code wants to read a draft field before the release. Use the preview environment’s own key, which holds drafts:read, and the X-Foir-Schema-Channel: draft header. Never put drafts:read on the key your production app ships.
  • Published schema still serves a model you deleted. The deletion waits for a release: release it (it is listed as a pending deletion), or keep the model if you changed your mind.
Last updated on