Skip to Content
Athanor

Registered documents

A client registers the operations its build will run, by hash. On live it can accept nothing else, so a query that was never registered cannot run against you.

A GraphQL endpoint that runs any query a caller sends is an endpoint a compromised integration can walk. Registered documents close that: a client registers the operations its build runs, by the SHA-256 of their text, and on live can choose to accept registered hashes and nothing else.

How a document is named

{ "documentId": "sha256:7f3c…", "variables": { "first": 50 } }

documentId is sha256: plus the hex SHA-256 of the document's text, exactly as registered. extensions.persistedQuery.sha256Hash is accepted too, for clients that speak Apollo's persisted-query shape. A request may carry query instead; on sandbox it always runs, and on live it runs only for a client in ad_hoc mode.

Registering

The SDK's publish step registers the published set against your client:

npx athanor-publish-documents live

Your own operations register the same way: run the script over your persisted-documents.json, or call registerDocument with the text from your build.

mutation RegisterDocument($input: RegisterDocumentInput!) {
  registerDocument(input: $input) {
    id
    hash
    operationName
    registeredAt
  }
}

Registration is the workload's own act, with its own token; a session cannot register for a client. A document that does not validate against the schema is refused with DocumentInvalid and the validator's words.

Modes

ModeLiveSandbox
ad_hocA document or a hash both work.Anything runs.
trusted_onlyA registered hash only; query is refused with TrustedOnly.Anything runs.

Switch a client's mode from Settings → API → Documents, or with setDocumentMode from the client itself. Set trusted_only once every operation the build runs is registered; the Documents page lists what is, and marks a document registered against an older schema.

When the schema changes

A registered document is checked against the schema it was registered under, and the hash it carries is kept. A schema change that would break a registered document fails our deploy, not your request: the operation you registered keeps running. The Documents page shows which documents were registered against an older schema so you can re-register from a fresh build.

On this page