@tenantFanOut runs a field’s query once for every tenant the request may see, in parallel, and returns the combined results as one list.

type Query {
  resultater: [Resultat] @tenantFanOut
}

The field must return a list of a tenant-scoped @table type. Which tenants are queried is decided per request: the tenants your request’s connection source names in tenants(), in its order, the tenants the request may span (see How-to: Tenant scoping). A tenant it names and then refuses from acquire contributes a failed element; a hosted tenant it does not name is never queried.

SDL signature

directive @tenantFanOut on FIELD_DEFINITION

The directive carries no arguments: fan-out cannot be inferred, it must be asked for, but what it fans over is a request-level fact, so there is nothing for a directive argument to say.

Element nullability chooses what happens when one tenant fails

With [Resultat], a tenant whose database is unreachable or times out contributes a single null element after the successful rows, and the response’s errors array carries an entry whose path points at that element; results from healthy tenants still return. With [Resultat!], any tenant failure nulls the whole field instead. Pick per field; there is no global switch.

Ordering

Results keep each tenant’s declared ordering (@defaultOrder or @orderBy) within that tenant’s rows and concatenate tenants in a stable order; they are not re-sorted globally. Fields below the fanned field need nothing extra: each row remembers its tenant, and nested selections (including @splitQuery children) read and route against the right database automatically.

Build-time rejections

@tenantFanOut is rejected at build time on: mutation fields, non-list fields, @asConnection fields, @lookupKey fields, interface- or union-typed fields, fields whose data is not tenant-scoped, fields where the tenant is already determined (a non-null argument bound to the tenant column, or any ancestor that fixed the tenant, including another @tenantFanOut), and @service / @routine fields (fan-out generates the SQL itself). In this first iteration the marker is supported on root fields and on fields of @table-backed parents; fields of class-, record-, or nesting-backed parents are rejected. It also rejects in builds that configure no <tenantColumn>: with no tenants, there is nothing to fan out over.

Optional arguments narrow the fan-out

A fanned field may take optional arguments that name the tenant, such as a nullable filmId: Int @field(name: "film_id") or a node id in a filter. When the request gives one, the field queries only the tenants its value names (several, for a list of ids); when it gives none, the field fans out as usual. Two such arguments narrow together: only tenants both name are queried. A tenant the request may not see is never queried, so a value naming one answers no rows from it, exactly as a filter on rows you cannot see would. A non-null argument naming the tenant is still rejected: the field would never fan out, so drop the directive.

A list that holds a null, or a filter element that leaves the argument out, narrows nothing, because such an element can match rows in any tenant. A narrowed field fails like any fan-out when a tenant it queries fails: a null element and a path-bearing error under [Resultat], a nulled field under [Resultat!].