Marks a table-bound type in a federated subgraph that vouches for the rows its own rules let the user see, so another subgraph can grant access to them through its database’s row-level security. Graphitron gives the type a voucher field, internalGraphitronVoucher: String, and every field you write on the type is absorbed into the voucher: sealed inside it, signed, and withheld from this subgraph’s published schema, which publishes the voucher alone. The accepting subgraph marks its matching type @accept.
SDL signature
directive @issue(scope: String!, ttl: String!, vouchesFor: String!) on OBJECT
| Parameter | Type | Meaning |
|---|---|---|
|
|
What the voucher is for. The accepting subgraph’s |
|
|
How long a voucher stays valid, as an ISO-8601 duration such as |
|
|
The absorbed fields the voucher vouches for, a field set as |
Canonical example
type VgsResultat @table(name: "soknad_vgs_resultat")
@issue(scope: "vgs-resultater", ttl: "PT5M", vouchesFor: "eierId") {
id: ID! @field(name: "vgs_resultat_id")
eierId: String! @field(name: "eier_id")
}
id and eierId are absorbed: the voucher carries them, signed, and the subgraph publishes VgsResultat with internalGraphitronVoucher alone. You do not write the voucher field; its name is the same in every subgraph, so the issuing and accepting sides cannot disagree on it. It is nullable, as on the accepting side: a row whose voucher cannot be made, one longer than VoucherCodec.MAX_TOKEN or carrying a number longer than VoucherCodec.MAX_NUMBER_TEXT, gets no voucher and an error at the voucher’s path, and the row itself is still answered. Name and type the absorbed fields exactly as the other subgraph’s key fields and vouched-for fields; a mismatch shows up as every voucher being rejected there.
What the subgraph publishes
-
Only the voucher field,
internalGraphitronVoucher: String, marked@inaccessibleso clients never see it. The absorbed fields, and any arguments they declare, are not part of the published schema, though they stay in the schema as written, where the editor shows and checks them. -
@key(fields: "internalGraphitronVoucher", resolvable: false)on the issuing type, after any key you wrote. The type is keyed by its voucher and not resolved here, so a router reaches the other subgraph’s entity from this one only through the voucher. The link imports@inaccessiblefor you. -
Every absorbed field is withheld whatever else is refused, so a schema whose
@issueis refused for another reason still never publishes them.
What is generated
-
The voucher field’s fetcher signs one voucher per row it is selected on, after the row is read. Whenever the voucher is selected, the row’s query also selects the absorbed fields' columns, so the voucher costs no extra statement. Each value is serialized by its field’s scalar before it is signed, so the voucher carries what a plain representation of the field would. A number whose text is longer than
VoucherCodec.MAX_NUMBER_TEXT, or a voucher longer thanVoucherCodec.MAX_TOKENcharacters (16384), fails the field with anIllegalArgumentExceptionrather than being signed, since the accepting subgraph would refuse it as malformed. -
Every voucher of one operation under one scope shares a random vouch id and an expiry of the operation’s start plus
ttl. A voucher is bound to no caller: within one supergraph operation the router calls both subgraphs for the same user, and the voucher never leaves the router. -
Every
Graphitron.runtime(…)overload, and everyGraphitronRuntimeconstructor, takes theVoucherKeyslast, so a runtime without them does not compile.VoucherKeys.issuing(keyId, privateKey)signs with a JDK Ed25519 key underkeyId, which every voucher carries. How-to: Voucher handover makes the keys and wires both subgraphs.
Constraints
Each refusal below is reported at the @issue, or at the absorbed field it is about.
| Code | Rule |
|---|---|
|
The schema has a federation |
|
The issuing type declares no field named |
|
The type is not also marked |
|
The issuing type carries no authored |
|
The issuing type is no node: a node is keyed by its id, which the voucher would absorb. |
|
No root operation field returns the issuing type: a voucher vouches for rows reached below a parent this subgraph’s rules admitted. A mutation payload’s field is no root field. |
|
|
|
|
|
Each vouched-for field names an absorbed field: not a name the type does not declare, not |
|
No vouched-for field is named twice. |
|
Each absorbed field is a single scalar value, not an enum, a list or an object. |
|
No absorbed field carries a directive giving it a value of its own, such as |
|
Each absorbed field reads a column of the issuing type’s table, by its |
Every absorbed field stays withheld whichever of these is reported.
See also
-
How-to: Federation keys, for how an entity is reached by its keys.