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

scope

String!

What the voucher is for. The accepting subgraph’s @accept(scope:) must name the same scope.

ttl

String!

How long a voucher stays valid, as an ISO-8601 duration such as PT5M. Every voucher an operation issues expires at the operation’s start plus this.

vouchesFor

String!

The absorbed fields the voucher vouches for, a field set as @key(fields:) spells one: whose rows are vouched for. The accepting subgraph’s @accept(vouchesFor:) names the same fields; the remaining absorbed fields are the fields of the vouched row’s key that vouchesFor does not name, its lookup part. A vouched-for field may itself be a key field, and naming every absorbed field leaves the lookup part empty: the key is then vouched for whole.

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 @inaccessible so 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 @inaccessible for you.

  • Every absorbed field is withheld whatever else is refused, so a schema whose @issue is 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 than VoucherCodec.MAX_TOKEN characters (16384), fails the field with an IllegalArgumentException rather 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 every GraphitronRuntime constructor, takes the VoucherKeys last, so a runtime without them does not compile. VoucherKeys.issuing(keyId, privateKey) signs with a JDK Ed25519 key under keyId, 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

VOUCHER_WITHOUT_FEDERATION_LINK

The schema has a federation @link: a voucher only makes sense where a router plans across subgraphs, and the key it is reached by needs the link.

VOUCHER_FIELD_NAME_TAKEN

The issuing type declares no field named internalGraphitronVoucher, the name Graphitron mints the voucher field under. Such a field is refused, not taken for the voucher, and is neither absorbed nor joined by a minted field.

VOUCHER_MARKERS_BOTH

The type is not also marked @accept: a type issues or accepts one voucher. Refused at each marker.

VOUCHER_ISSUE_ON_KEYED_TYPE

The issuing type carries no authored @key, which would let a router reach the other subgraph’s entity without the voucher.

VOUCHER_ISSUE_ON_NODE

The issuing type is no node: a node is keyed by its id, which the voucher would absorb.

VOUCHER_ISSUE_ON_ROOT_TYPE

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.

VOUCHER_TTL_INVALID

ttl is an ISO-8601 duration of hours, minutes and seconds, such as PT5M.

VOUCHER_VOUCHES_FOR_EMPTY

vouchesFor selects at least one field.

VOUCHER_VOUCHED_FOR_NOT_ABSORBED

Each vouched-for field names an absorbed field: not a name the type does not declare, not internalGraphitronVoucher, not a nested selection.

VOUCHER_VOUCHED_FOR_REPEATED

No vouched-for field is named twice.

VOUCHER_MEMBER_NOT_SCALAR

Each absorbed field is a single scalar value, not an enum, a list or an object.

VOUCHER_MEMBER_COMPUTED

No absorbed field carries a directive giving it a value of its own, such as @nodeId, @service, @routine, @reference, @externalField or @pivot: the voucher reads each off the issuing row.

VOUCHER_MEMBER_COLUMN_UNRESOLVED

Each absorbed field reads a column of the issuing type’s table, by its @field(name:) or its own name.

Every absorbed field stays withheld whichever of these is reported.

See also