Two subgraphs hold two halves of one story. Subgraph A knows that an application has results and who owns each; subgraph B owns the results themselves, behind row-level security on their owner. A client asking A for an application’s results should see B’s results for exactly those owners, without B trusting the client’s word for whose rows they are.
A voucher carries that word for you. A signs one per row it reads: the row’s lookup key and its vouched-for values, here the owner. The router hands it to B as the entity’s key, and B checks the signature, reads the owner off it, and resolves the entity on a connection your connection source sets up for the owners the request’s vouchers carry. Your database’s policies then decide what those owners' rows the request may see; Graphitron never reads the voucher’s values as data.
1. Subgraph A issues
Mark the type @issue. Graphitron gives it the voucher field internalGraphitronVoucher, and every field you write on the type is absorbed into the voucher, signed and withheld from what A publishes; vouchesFor names the absorbed fields whose values become the vouched-for part, and the rest are the lookup part, named and typed as the fields of B’s key that B does not vouch for:
"Subgraph A: an application's results, each vouched for to subgraph B. `id` and `eierId` are absorbed into the voucher under B's names and types, `eierId` being vouched for, and A publishes VgsResultat with the voucher alone."
type Query {
applications: [Application!]!
}
type Application @table(name: "vouched_application") {
results: [VgsResultat!]!
@reference(path: [{key : "vouched_application_result_application_id_fkey"}])
}
type VgsResultat
@table(name: "vouched_application_result")
@issue(scope: "vgs-resultater", ttl: "PT5M", vouchesFor: "eierId") {
id: ID! @field(name: "result_id")
eierId: String! @field(name: "owner_id")
}
A publishes VgsResultat keyed by internalGraphitronVoucher alone, not resolvable here and kept from clients, so a router reaches B’s entity from A only through the voucher. The store states the vouched-for field and the minted key:
| position | type_name | field_name |
|---|---|---|
|
|
|
| type_name | role | fields | resolvable |
|---|---|---|---|
|
|
|
|
2. Subgraph B accepts
On B, the entity is table-bound and keyed by its own key. Mark the type @accept with the same scope and the same vouched-for fields; Graphitron gives it the same internalGraphitronVoucher field:
"Subgraph B: the results themselves, resolved by their own key and by the voucher A signs, the details read in the same SELECT on the connection your source leases for the vouched-for owner."
type Query {
results: [VgsResultat!]!
}
type VgsResultat
@table(name: "vouched_result")
@key(fields: "id")
@accept(scope: "vgs-resultater", vouchesFor: "eierId") {
id: ID! @field(name: "result_id")
eierId: String! @field(name: "owner_id") @inaccessible
grade: Int!
details: [Detail!]! @reference(path: [{key : "vouched_result_detail_result_id_fkey"}])
}
type Detail @table(name: "vouched_result_detail") {
subject: String!
}
B resolves VgsResultat by id as before, and by internalGraphitronVoucher beside it. The store states the vouched-for field and the minted key:
| type_name | field_name |
|---|---|
|
|
| type_name | role | fields | resolvable |
|---|---|---|---|
|
|
|
|
Name and type the absorbed fields on A exactly as B’s key field and vouched-for field: a mismatch shows up as every voucher being rejected on B.
3. Keys
Make one Ed25519 key pair per signing subgraph. With OpenSSL 1.1.1 or later:
openssl genpkey -algorithm ed25519 -out voucher-2026-11.pem # private key, stays with A
openssl pkcs8 -topk8 -nocrypt -in voucher-2026-11.pem -outform DER -out voucher-2026-11.key.der
openssl pkey -in voucher-2026-11.pem -pubout -outform DER -out voucher-2026-11.pub.der # public key, for B
or with the JDK alone, whose encodings are the same PKCS#8 and X.509 DER:
KeyPair pair = KeyPairGenerator.getInstance("Ed25519").generateKeyPair();
byte[] privateDer = pair.getPrivate().getEncoded(); // PKCS#8, A's secret
byte[] publicDer = pair.getPublic().getEncoded(); // X.509, B's verification key
Keep the private key in A’s secret store only; the public key is not secret and goes to every subgraph that accepts A’s vouchers. The key id you sign under (2026-11 below) is a label of your choosing, carried in every voucher, which B uses to pick the public key; naming it for when the pair was made keeps rotation readable.
Both runtimes take the generated VoucherKeys as the last argument of every Graphitron.runtime(…) overload, so a runtime without them does not compile. The keys are Ed25519 from the JDK; load them from wherever your platform keeps secrets:
// Subgraph A: signs under a key id
PrivateKey signing = KeyFactory.getInstance("Ed25519")
.generatePrivate(new PKCS8EncodedKeySpec(privateDer));
var runtimeA = Graphitron.runtime(SQLDialect.POSTGRES, settings,
VoucherKeys.issuing("2026-11", signing));
// Subgraph B: verifies by the key id a voucher carries
PublicKey verifying = KeyFactory.getInstance("Ed25519")
.generatePublic(new X509EncodedKeySpec(publicDer));
var runtimeB = Graphitron.runtime(SQLDialect.POSTGRES, settings,
VoucherKeys.accepting(Map.of("2026-11", verifying)));
Where the keys live. Keep the key pair in your secret store, for example HashiCorp Vault’s key/value engine: the private key under A’s path, and every public key B should accept, each under its key id, where B reads its configuration. Both runtimes read them once at startup, and signing and verifying stay in process. Do not reach for a signing service such as Vault’s Transit engine here: Graphitron signs one voucher per row read, so a remote signature would cost one round trip per row, and an Ed25519 key is small and cheap enough to hold in memory. Keeping the pair in the secret store is what makes rotation a matter of writing new secrets:
To rotate, add the new public key to B under a new id and deploy B, then switch A to sign with it; drop the old id from B once the vouchers signed with it have expired, ttl after they were issued. VoucherKeys is an interface, so a key that must never leave a signing service can still be served by implementing it, at that round trip per voucher.
4. B’s connection source mounts the vouched-for set
A vouched-for value never filters anything in B’s SQL. Every value the request’s vouchers carry goes into one set on the generated ConnectionKey, key.vouchedFor(): a set of ConnectionKey.VouchedFor rows, one per distinct value, with a component per vouched-for field, here eierId(). B reads every vouched entity of the request on the one connection its source leases for that key. Set the set where your policies read it:
var source = ConnectionSources.mounting(
key -> dataSource,
(connection, key) -> DSL.using(connection, SQLDialect.POSTGRES)
.execute("select set_config('app.vouched_owners', ?::text, false)",
(Object) key.vouchedFor().stream().map(VouchedFor::eierId).toArray(String[]::new)),
(connection, key) -> DSL.using(connection, SQLDialect.POSTGRES)
.execute("select set_config('app.vouched_owners', '{}', false)"));
var input = Graphitron.newOwnedExecutionInput(source).query(query).build();
The key whose set is empty is the request’s own connection, for every field outside a vouched entity; here it gets no owner, so it sees no results. The policy tests the row’s membership in the set:
ALTER TABLE vouched_result ENABLE ROW LEVEL SECURITY;
CREATE POLICY vouched_result_owner ON vouched_result
USING (owner_id IN (SELECT unnest(coalesce(nullif(current_setting('app.vouched_owners', true), ''), '{}')::text[])));
Write the membership as IN (SELECT unnest(…)). PostgreSQL runs it as a hashed subplan: the setting is parsed once per statement and each row is one hash probe, so a thousand owners cost what one does. owner_id = ANY (current_setting(…)::text[]) admits the same rows but parses the setting again for every row it filters; measured against a thousand owners it is about ten times slower on an indexed lookup and several hundred times slower on a scan.
With more than one vouched-for field, each voucher’s values are one row of the set, so a policy never pairs one voucher’s organisation with another’s person. Write the set as a JSON array of objects and test the row’s values together; here both are integers:
(connection, key) -> DSL.using(connection, SQLDialect.POSTGRES)
.execute("select set_config('app.vouched_pairs', ?, false)",
key.vouchedFor().stream()
.map(v -> "{\"org\":" + v.orgId() + ",\"person\":" + v.personId() + "}")
.collect(Collectors.joining(",", "[", "]")))
CREATE POLICY vouched_enrolment_pair ON vouched_enrolment
USING ((org_id, person_id) IN (
SELECT v.org, v.person
FROM jsonb_to_recordset(coalesce(nullif(current_setting('app.vouched_pairs', true), ''), '[]')::jsonb)
AS v(org int, person int)));
One connection for every value. A row read below one vouched entity is read on a connection that can also see the other admitted owners' rows, so a join that strays from one owner’s rows to another’s is not caught by the database. It grants the caller nothing it was not vouched: A vouched every admitted value to the same caller in the same request. Where each entity must be read in isolation, vouch for the entity’s own key (step 6): each value is then one entity.
The set is type-blind. A VouchedFor row names values, not the accepting type that admitted them, and every accepting type in a build vouches for fields of the same names and types (VOUCHER_ACCEPT_VOUCHED_FOR_DIFFERS). Types share values only by sharing those names, as owners do by design: eierId names one owner on every accepting type.
A session variable is a convention any SQL on the connection could overwrite; see the security guide for the stronger fences, a definer-rights routine or a token verified in the database.
5. What a client sees
-
A voucher that fails any check (signature, expiry, scope, the
__typenameit was signed for, a value no column takes) rejects the whole request, and no connection is taken for its representations:GraphQL.executethrows the generatedVoucherRejectedException, naming the check and nothing from the token. Answer it fromGraphitron.requestRejection(thrown), usually with 401 or 403. -
A router sends every representation bound for this subgraph in one
_entitiescall, so a list whose rows belong to different owners presents them all at once. Every owner they carry is read on the one connection, up to a cap on the distinct vouched-for values one request admits: a thousand unless your runtime says otherwise. The first values in representation order fill the set; each representation whose value is past the cap answersnullwith an error at its own index naming the limit and no value, so the router places it at that row’s path, takes no connection, and the rest of the request is answered. -
The cap bounds what one request costs B’s database, since every row read under the policies tests membership in the set; it grants nothing. Set it with
Graphitron.runtime(…).withVouchedValueLimit(env → limit), asked once per request with the_entitiesfield’s environment, so a batch integration can be given more. An answer below 1 admits no value; answerInteger.MAX_VALUEfor no practical bound. If the limit throws, the thousand stands. -
A plain representation of B’s own key resolves on the request’s own connection, under the caller’s own access: a voucher only ever adds access.
-
A row A could not sign, its voucher too long or a number in it too long, has a
nullvoucher and an error at its path on A, and the row is still answered there. On B, a representation carrying thatnullvoucher answersnulland never rejects the request. -
Every redemption, rejection and representation turned away by the cap is logged with its vouch id, scope and outcome on the
no.sikt.graphitron.voucher.auditlogger at INFO; never the token or its values. -
A build that accepts vouchers has no escape hatch:
Graphitron.newExecutionInput(dsl, …)is not generated.
6. A voucher per entity
When B’s access should follow A’s access to each row rather than to an owner, vouch for the row’s own key. Each field of the key a voucher decodes to is supplied by exactly one of its sections: a key field vouchesFor names by the vouched-for section, every other by the lookup section. With the key wholly vouched for, the lookup section is empty and the key both finds the row and decides access.
A cannot issue on a type a root field returns, so the voucher sits on a type reached through a field: the case’s event log, the same row read again by joining the case to itself over its primary key. Every absorbed field is vouched for:
"Subgraph A, vouching for each case by its own id: a case cannot issue itself, since a root field returns it, so the voucher sits on its event log, the same row read again by joining the case to itself over its primary key. Every absorbed field is vouched for, so the voucher's lookup section is empty."
type Query {
cases: [Case!]!
}
type Case @table(name: "vouched_case") {
title: String!
eventLog: CaseEventLog @reference(path: [{key : "vouched_case_pkey"}])
}
type CaseEventLog
@table(name: "vouched_case")
@issue(scope: "case-events", ttl: "PT5M", vouchesFor: "caseId") {
caseId: Int! @field(name: "case_id")
}
B vouches for its own key, the case’s id:
"Subgraph B, vouching for its own key: a case's event log is vouched for by the case's id, which is also the key the voucher decodes to, so the voucher's lookup section is empty and every row of a list presents a vouched-for value of its own. The events are read on the connection your source leases for the set of case ids the operation admitted."
type Query {
caseEventLogs: [CaseEventLog!]!
}
type CaseEventLog
@table(name: "vouched_case")
@key(fields: "caseId")
@accept(scope: "case-events", vouchesFor: "caseId") {
caseId: Int! @field(name: "case_id") @inaccessible
events: [CaseEvent!]! @reference(path: [{key : "vouched_case_event_case_id_fkey"}])
}
type CaseEvent @table(name: "vouched_case_event") {
what: String!
}
| type_name | field_name |
|---|---|
|
|
The source sets the case ids, and the policies on the case and its events test membership:
(connection, key) -> DSL.using(connection, SQLDialect.POSTGRES)
.execute("select set_config('app.vouched_cases', ?::text, false)",
(Object) key.vouchedFor().stream().map(VouchedFor::caseId).toArray(Integer[]::new))
CREATE POLICY vouched_case_vouched ON vouched_case
USING (case_id IN (SELECT unnest(coalesce(nullif(current_setting('app.vouched_cases', true), ''), '{}')::int[])));
CREATE POLICY vouched_case_event_vouched ON vouched_case_event
USING (case_id IN (SELECT unnest(coalesce(nullif(current_setting('app.vouched_cases', true), ''), '{}')::int[])));
What it means for you:
-
A list of rows presents one vouched-for value per row, and the router sends them in one call, so the cap is sized to a list: a page of more than a thousand rows needs
withVouchedValueLimit. -
Each value is one entity, so what one connection for every value gives up (step 4) is nil: a row of one case’s subtree is read on a connection that can see only cases A vouched for to the same caller.
-
It is in practice the build’s one accepting type. Every accepting type vouches for fields of the same names and types, so a second type with a key of its own is refused, and one whose key is made to share the name shares values: a policy on either table admits the other’s ids.
-
If your vouchers vouch for a second field reading the key’s column today, a
nasjonalIdForVoucherbeside the keynasjonalId, that form keeps working. To drop it, vouch for the key field itself on both sides together: an older A’s voucher carries the second field where the new B expects the key field, so the two deploy as one, and a voucher lives itsttl, the window a split deploy fails in.VouchedFor’s component is named for the vouched-for field, so your source reads `VouchedFor::nasjonalIdafter the move.
Limits for now
-
B reads the entity and every field below it on the vouched connection: a field its SELECT reads in the entity’s own statement, and a split query, a routine, a polymorphic field or a
@servicebelow it on the connection the entity hands down. A connection-typed field below it is refused withVOUCHER_ACCEPT_NOT_GENERATEDuntil it too reads on that connection. -
B has no
<tenantColumn>: a voucher is not yet paired with a tenant.