Backs a field with a database routine rather than a catalog table. Supported today is the table-valued function (PostgreSQL RETURNS TABLE / SETOF): jOOQ generates such a function as a first-class catalog Table<R>, so the rewrite reads its result the way it reads a table’s rows, projecting Type.$project(…) against it with the same selection narrowing. When the field’s path ends on the routine, the element type’s rows are the routine’s result: its fields read the function’s result columns, and the type is not bound to any table (see The type’s rows are the routine’s result). The difference from a plain catalog read is the row source: instead of the bare Tables.X singleton, the rewrite calls the schema’s generated Routines convenience method with the routine’s IN parameters bound from GraphQL field arguments or from columns of the table the path stands on, both named through argMapping.
@routine is the seam for reading from a stored function whose result set parameterises on its inputs, such as an access-control function that returns the rows a caller may see, and, on Mutation, for writing through a stored function that performs the mutation itself (see Writes on Mutation). The routine’s shape (table-valued) is read off its jOOQ kind, not declared.
The directive works at root and at child positions, and it composes with @reference: the directives on a field, read left to right, describe the path your data travels, so the routine’s result table can supply the field’s rows, feed further joins, or sit between catalog tables (see Composing with @reference).
SDL signature
directive @routine(
name: String!
argMapping: String
) repeatable on FIELD_DEFINITION
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
|
|
(required) |
The database routine name, optionally schema-qualified ( |
|
|
(empty) |
Binds routine IN parameters ( |
Canonical example
A table-valued access-control function backing a root list field. The element type carries no directive of its own: the routine ends the field’s path, so the type’s rows are the routine’s result. The three TEXT IN parameters bind from GraphQL arguments:
type Tilgang {
organisasjonskode: Int
rollekode: String
}
type Query {
tilganger(env: String!, serviceId: String!, feideId: String!): [Tilgang!]!
@routine(
name: "tilganger_for_feidebruker_med_fs_fiktivt_fnr"
argMapping: "pEnv: env, pServiceId: serviceId, pFeideId: feideId"
)
@defaultOrder(fields: [{name: "organisasjonskode"}, {name: "rollekode"}])
}
The rewrite emits select(Tilgang.$project(…)).from(Routines.tilgangerForFeidebrukerMedFsFiktivtFnr(env, serviceId, feideId)).where(noCondition()).orderBy(…).fetch(). A query selecting only organisasjonskode projects only that routine-result column.
The @defaultOrder is required here rather than decorative: the routine result is the chain’s last node and Tilgang is bound to no table, so there is no primary key to fall back on and nothing can supply a deterministic order unless the schema names it. See The read surface.
The type’s rows are the routine’s result
A field whose path ends on a @routine gives the type it returns the routine’s result: each object of that type is one row the function returned. This holds at root and child positions alike, after @reference hops or with none. It is a fact about what the field returns, not about the type, so it is not a table binding:
-
The type’s fields read the result’s columns. A scalar field resolves against the function’s result columns by
@field(name:)or, absent that, by its own name, exactly as it would against a table’s columns.Tilgang.rollekodeabove reads therollekodecolumn of `tilganger_for_feidebruker_med_fs_fiktivt_fnr’s result. -
The type is not table-bound. Nothing that asks which table stands for a type answers with the function. A function is called with arguments and a table is not, so a type standing for a function’s rows would need the call before any of its rows existed.
-
The type is free to be returned elsewhere. Two routines returning the same row shape can share one type, each field giving it the result of the routine it calls.
So @table cannot name a function: @table(name: "tilganger_for_feidebruker_med_fs_fiktivt_fnr") on Tilgang fails the build, and the editor reports it as GRAPHITRON_TABLE_NAMES_ROUTINE. Remove the directive; the field carrying @routine is what says where the type’s rows come from. It belongs to the field because that is where the routine is called: a @table on the type would read as a claim that it is a stored table, would have to repeat the routine’s name and agree with it, and would weld the type to one routine.
The read surface: filtering, ordering and pagination
A @routine puts a function call in the FROM clause. WHERE and ORDER BY are different clauses of the same statement, so a routine-backed field filters and sorts like any other field: @condition, filter arguments, @defaultOrder and @orderBy all compose, at root and at child positions alike, and they resolve against the terminus of the field’s table chain (the last node, which is the table the field’s element type is bound to).
What the call binds, and what filters its result
An argMapping entry binds the input it names to a routine parameter, and only that input. A leaf it binds feeds the routine parameter and never reaches the WHERE clause; every other input field of the same argument filters the result exactly as it would on a table-backed field, binding through @field(name:) or, absent that, by a case-insensitive match on its own name. So one input object can carry both halves, which is usually how an author wants to spell it:
input ActorFilmFilter {
actorRef: ID! @nodeId(typeName: "Actor") # bound: projects actor_id into pActorId
minLength: Int! # bound: feeds pMinLength
title: String # filters the result: WHERE title = ?
}
type Query {
actorFilms(filter: ActorFilmFilter!): [ActorFilm!]
@routine(
name: "films_for_actor"
argMapping: "pActorId: filter.actorRef.actor_id, pMinLength: filter.minLength"
)
@defaultOrder(fields: [{name: "film_id"}])
}
The two bound leaves above are bound in two different ways: actorRef through the key projection, which hands pActorId a decoded actor_id, and minLength as a plain scalar read. title is bound by nothing, and what it resolves against is the chain terminus, here the function result itself.
Two consequences follow, and both are build errors rather than silence:
-
A surviving leaf that binds nothing fails the build, with the message it already gets on a table-backed field: it names no column of the terminus and carries no
@condition. Nothing about being inside a routine argument exempts it. -
A bound leaf carrying
@fieldor@conditionis a directive conflict. It asks for a predicate it will never get, the routine parameter having bound it first.@nodeIdon a bound leaf is not a conflict: there the directive is a decode instruction the key projection carries out, not a filter.
One rule governs the ordering, and it is the rule every list field already lives under:
A list result is ordered, by an authored @defaultOrder when there is one and otherwise by the primary key of the table the field’s target type is bound to.
A function’s result type is bound to no table unless its own @table binds it (see The type’s rows are the routine’s result), so the two terminus kinds land differently, and that is the whole of the routine-specific story:
-
Catalog terminus (a
@referencehop follows the routine, or the return type’s own@tablemakes the hop implicit): the target type is bound to an ordinary table, the primary-key fallback applies, and a list field needs no ordering directive at all. -
Routine terminus (the routine is the last node and the return type carries no
@table): there is no key to fall back on, so a list field must name its order over the function’s own result columns with@defaultOrder(fields: […]), or take one from a non-null, single-valued@orderByargument. An@orderByargument a client may leave out (a nullable one) is no order stated: the query that omits it would have nothing to sort by. Omitting both is a build error,LIST_ORDER_UNDETERMINED, offering the two fixes: add@defaultOrdernaming the result’s columns withfields:, or make a single-valued@orderByargument non-null.@defaultOrder(primaryKey: true)there is a build error too, and lists the result columns as candidates.
@asConnection follows from the same rule, with no routine-specific caveat. Keyset pagination needs an ordering, which is what the two bullets above are about; given one, the seek predicate is an ordinary WHERE row-value comparison and a function in the FROM is a table expression like any other. A chain with @reference hops paginates too, and its totalCount counts the joined chain rather than the terminus alone.
At a child position the read surface composes on a field fetched in a query of its own, and a child connection always is one: it is batched across parents through a DataLoader and each parent pages its own rows (see Fetch forms and @splitQuery). Filters, an @orderBy argument and @asConnection all compose there. On the inline list form, fetched in the parent’s statement, a @defaultOrder is the whole read surface. Because the batch is keyed by what the routine reads off the parent row, a routine child connection needs at least one parameter bound to a parent column, or a table step before the routine to key it. On a Mutation field a Connection return is a build error, the write’s post-commit re-read being keyed rather than paged.
Where a parameter takes its value
Every IN parameter of the routine takes its value from one place, named by the argMapping entry for it, or by the parameter’s own name where no entry names it:
-
A bare name is an argument of the field. The value is the argument’s, or the leaf a dot-path walks to inside it.
-
$source.<column>is a column of the row the routine is applied to. That is the enclosing type’s row when the routine comes first in a child field’s path, and the last hop’s table after@referencehops. A column is matched by its SQL name, without regard to case. The call becomes correlated: SQL evaluates it once per row of that table, viaCROSS JOIN LATERAL, inside the same statement that fetches the parent (the inline correlated multiset), so there is no per-row round trip. A column’s Java type must be the parameter’s.
A bare name never binds a column, so adding a column to a table never changes what a call reads. A name that is no argument, or a $source.<column> naming no column of that table, leaves the parameter with no value, reported as GRAPHITRON_PARAMETER_UNFILLED at the @routine. A root field has no such row, so $source is an error there and every parameter binds an argument.
type Actor @table(name: "actor") {
films(minLength: Int!): [ActorFilm!]
@routine(
name: "films_for_actor"
argMapping: "pActorId: $source.actor_id, pMinLength: minLength"
)
@defaultOrder(fields: [{name: "film_id"}])
}
pActorId reads each actor row’s actor_id, a column of actor and no argument of films; pMinLength reads the GraphQL argument. Mixed calls like this emit the routine’s Field-overload surface, so both bindings are typed at the call site.
The @defaultOrder here is not a child-position speciality; see The read surface for the one rule that puts it there.
Composing with @reference: the table chain
A field’s table chain is the concatenation, in written order, of the implicit head (the enclosing type’s table, at child positions) and each directive application’s contribution: @routine contributes its result table as a node, @reference contributes hops. The last node must be the field’s @table type, or the routine’s result where the routine is last and the field’s type has no @table. Where the routine is last and the field’s type does carry @table, the path takes one more step that you do not write: from the routine’s result to that table, keyed by name as a written {table:} hop out of a routine result is (see below). Order is load-bearing; see the order contract on the @reference page.
Every position falls out of that one rule. In these examples (from the sakila example schema) recentFilms sits on Actor and the other two fields sit on Film:
# Routine then hops: the routine supplies the rows, a hop lands on the film table.
recentFilms(minLength: Int!): [Film!]
@routine(name: "films_for_actor",
argMapping: "pActorId: $source.actor_id, pMinLength: minLength")
@reference(path: [{table: "film"}])
@defaultOrder(primaryKey: true)
# Hops then routine: the hop reaches the junction first, so actor_id is a column
# of film_actor (the table the path stands on), not of the enclosing Film row.
castFilms(minLength: Int!): [ActorFilm!]
@reference(path: [{table: "film_actor"}])
@routine(name: "films_for_actor",
argMapping: "pActorId: $source.actor_id, pMinLength: minLength")
@defaultOrder(fields: [{name: "film_id"}])
# Sandwich: hops in, routine, hop back out to a catalog terminus.
castRecentFilms(minLength: Int!): [Film!]
@reference(path: [{table: "film_actor"}])
@routine(name: "films_for_actor",
argMapping: "pActorId: $source.actor_id, pMinLength: minLength")
@reference(path: [{table: "film"}])
@defaultOrder(primaryKey: true)
A hop out of a routine result has no foreign key to ride (a function result carries no FK metadata), so a {table:} element there keys by name matching: the target table’s primary-key columns must be exposed, by SQL name, among the routine’s result columns. films_for_actor exposes film_id, film’s PK, so the hop above resolves; a condition: element is the escape hatch when names do not line up.
The single name-matched hop is also implicit, in two places, because in both the only thing a @reference would supply is the target table name and a return type already carries it. The first is the routine’s own field: where the routine ends the path and the field returns a @table type, the hop from the result to that table is inferred.
type Query {
recentFilmsForActor(actorId: Int!, minLength: Int!): [Film!]! # Film is @table(name: "film")
@routine(name: "films_for_actor", argMapping: "pActorId: actorId, pMinLength: minLength")
}
reads exactly as the same field with @reference(path: [{table: "film"}]) written after the routine. The second is a @table-bound child of a routine-result parent, which needs no @reference at all:
type Query {
mineTilganger: [Brukertilgang!]!
@routine(name: "mine_tilganger") # a table-valued function
@defaultOrder(fields: [{name: "rollekode"}])
}
type Brukertilgang { # its rows are mine_tilganger's result, by the field above
tilgangsrolle: Tilgangsrolle # Tilgangsrolle is @table(name: "rolle")
}
An explicit @reference(path: [{table: "rolle"}]) stays legal and resolves identically; writing it is optional, not wrong. What has no implicit spelling is a multi-hop path out of a routine result, or a join the name-match cannot key: both still need the directive, and the build error names the missing key column and points at the condition: element rather than at foreign keys.
Binding a parameter to a node id’s key column
An ID field annotated @nodeId carries a base64-encoded node identity on the
wire, not the key it encodes. A routine IN parameter almost always wants the key. Open the node id
with the key column you want and the binding decodes it for you:
input OpprettFeideApplikasjonInput {
navn: String!
organisasjonId: ID! @nodeId(typeName: "Organisasjon")
serviceId: String!
}
type Mutation {
opprettFeideApplikasjon(input: OpprettFeideApplikasjonInput!): OpprettFeideApplikasjonPayload
@routine(
name: "opprett_feide_applikasjon"
argMapping: "pNavn: input.navn, pOrganisasjonskode: input.organisasjonId.organisasjonskode, pServiceId: input.serviceId"
)
}
organisasjonskode is not a field of any SDL type. It is a key column of the node type the
@nodeId names, so the segment means "decode this node id and project that column out of the
decoded key". The generated fetcher decodes the id once into `Organisasjon’s own record and reads
the named column off it, before the write transaction opens.
This is the same rule the dot always followed: a dot opens the thing at that position, and what it
opens into depends on what the thing is. It is documented in full under
Binding a parameter to a nested input field, and it works the same
way at every directive that accepts an argMapping.
Which columns are openable comes from the node type, not from the routine: whatever
@node(keyColumns:) declares, or the table’s key metadata where it does not. Matching
is case-insensitive, so the SQL spelling and the generated spelling are one answer.
Where the node type’s key is a single column you may leave the leaf closed:
pOrganisasjonskode: input.organisasjonId names that column, there being no other it could name, and
the parameter receives it exactly as the spelled-out form does. That holds wherever the @nodeId
sits, an argument of the field (pOrganisasjonskode: organisasjonId) as much as an input field below
one. Naming the column is then a matter of saying out loud what the build would infer, which is worth
doing where the reader benefits.
Four things are build errors rather than surprises at runtime, and one is not supported yet:
-
Binding a
@nodeIdwhose key is more than one column without saying which. One binding carries one value, and nothing inpOrganisasjonskode: input.organisasjonIdsays which of the two it is. The build stops, states the count, and lists the columns you could have named. It says the same where the node type resolves no key columns at all, the remedy there being@node(keyColumns:)on that type. -
@nodeIdwithouttypeName:at this position. A bare@nodeIdinfers its target from the containing table, and a routine parameter has no containing table, so there is nothing to infer from. Name the type. -
A key column the parameter cannot take. Projecting an
Integercolumn into aStringparameter is a build error naming the column, its type and the parameter’s, rather than a compile error in generated code you did not write. Bind a parameter of the column’s own type, or project a column the parameter can take. The check needs both types: where the parameter’s type cannot be resolved, a routine whose call surface was not captured, the build lets it through and your compiler is the backstop. -
A
@nodeIdargument a parameter takes by name, with noargMappingentry. A parameter named like the argument would receive the whole decoded key, and a routine parameter holds one value, so the build refuses it (NODE_ID_KEY_ARITY_EXCEEDS_SLOT). Write the entry,pCustomerId: customerId, and the key column is projected as above. -
A list of node ids bound to a routine parameter is not decoded into an array of a key column yet (
ROUTINE_NODE_ID_LIST_UNSUPPORTED).
An omitted node id is not one of them. A @nodeId the client leaves out, or sends as null, has
nothing to decode, so the projection is null and the parameter receives null. That holds wherever
the absence sits on the path: a nullable @nodeId leaf, and a non-null one inside an input object the
client omitted, project the same null. Express an optional filter with a function that tolerates a
NULL parameter, since what an absent value means is the function’s to define and not the generator’s;
a function whose parameter is not NULL-tolerant fails inside the database, which is that function’s
own declared contract. Only absence is affected: a malformed node id, and one encoded for another node
type, still fail the request as client errors before the routine runs.
Writes on Mutation
On a Mutation field, the routine call is the write, and it commits before the follow-up query runs. @routine names a VOLATILE set-returning function, and two return shapes are admitted: with @reference, the field returns the table the chain reaches; without it, the field returns a payload whose data field declares its own path.
Every input the field advertises must feed a parameter
A Mutation @routine field resolves no filter surface at all. The call is the write, and the post-commit re-read below is keyed by the captured columns rather than filtered, so nothing on a write seat reads input except the routine’s own parameter list. An input the argMapping does not bind therefore reaches nothing, and that is a build error naming the input, leaf by leaf and argument by argument: a field of an input object the bindings never name, and an argument slot the bindings never name, fail alike. It is the same verdict a DML mutation’s unbound input field already gets, and the remedy is the same: bind it, or take it off the schema.
There is no spelling yet for an input deliberately left unread, the Relay clientMutationId pattern or an idempotency key among them. Neither mutation kind has one, and nothing echoes such a value back into a payload.
The chain form
The chain form is @routine plus at least one @reference hop landing the field’s @table type.
type Rental @table(name: "rental") {
rentalId: Int! @field(name: "rental_id")
}
type Mutation {
rentFilm(inventoryId: Int!, customerId: Int!): [Rental!]!
@routine(
name: "rent_film"
argMapping: "pInventoryId: inventoryId, pCustomerId: customerId"
)
@reference(path: [{table: "rental"}])
}
The generated fetcher is two statements. Statement 1 executes the routine inside a transaction and captures only the columns the first hop’s key needs from the routine’s result rows (here rental_id); on the escape-hatch path that transaction commits when the statement returns, and on the owned-connection path it joins the mutation field’s own transaction and commits nothing until the field completes. Statement 2 is a read-only SELECT anchored on the first hop’s table, keyed by the captured values, with any remaining hops joined as in a read chain, projecting the terminus type. The routine never appears in statement 2: re-invoking it would re-execute the write. The field’s return therefore always binds to the post-commit re-read, never to the routine’s own rows, so the response observes committed state without exception.
An SQL error from the routine rolls the transaction back and surfaces on the mutation field like any DML error. On the escape-hatch path a read error in statement 2 cannot undo the already-committed write (the same caveat the DML mutations carry); on the owned-connection path statement 2 runs inside the field’s transaction, so a read error there fails the field and rolls the routine’s write back (Transactions on the owned-connection path).
The payload carrier
Without @reference, the field returns a payload carrier: a plain Object wrapping exactly one @table-element data field, plus an optional errors-shaped field (the same carrier mold the DML and @service mutations admit).
type RentFilmPayload {
rental: Rental # the data field — must be nullable
errors: [RentFilmError] # optional typed errors channel
}
type Mutation {
rentFilmPayload(inventoryId: Int!, customerId: Int!): RentFilmPayload
@routine(
name: "rent_film"
argMapping: "pInventoryId: inventoryId, pCustomerId: customerId"
)
}
When the field takes a wrapper input instead of flat arguments, argMapping walks into it. This is the shape a Relay-style mutation has, and it needs no SDL restructuring:
input RentFilmInput {
inventoryId: Int!
customerId: Int!
}
type Mutation {
rentFilmPayloadNested(input: RentFilmInput!): RentFilmPayload
@routine(
name: "rent_film"
argMapping: "pInventoryId: input.inventoryId, pCustomerId: input.customerId"
)
}
The two statements become: the routine call and the key capture commit as statement 1; the data field’s SELECT is the post-commit re-read, owned by the payload field rather than the mutation fetcher. The data field’s path is implicit — the single name-matched hop to its own element’s table: the element table’s primary-key columns must be exposed, by SQL name, among the routine’s result columns (rent_film exposes rental_id, rental’s PK). When a key column is not exposed, the build error names it with a candidate hint; the fix is exposing the column from the routine — a condition: join is no escape hatch here, because a condition has no key tuple to capture.
The errors-shaped field, when present, is the typed error channel: an exception the @error handlers match renders as { rental: null, errors: [<typed error>] } with no field error (see the errors-channel how-to).
The data field must be nullable, and the reason is a second, distinct null-data outcome: the post-commit re-read runs at read time under the caller’s identity, so a read policy (row-level security) can legitimately hide the row the routine just committed. That renders { rental: null, errors: null } as a success, with nothing raised and nothing dispatched; a non-null data field would let non-null propagation null the whole payload and destroy the errors list, so it is rejected at build time. A list data field is exempt from that reason, since a re-read that finds no row renders an empty list, but not from the errors field’s: with an errors field present a list data field may be non-null, and then renders [] on the error path as it does on a re-read that finds no row.
Two spellings are deliberately not admitted. @routine + @reference on the mutation field with a carrier return is rejected as a directive conflict: the reference path’s seat is the payload’s data field, the field whose rows it fetches, so drop @reference from the mutation field. And @reference on the data field itself (the explicit path declaration, single- and multi-hop alike) is deferred with a pointer to its follow-up; the implicit single name-matched hop is the shipped shape.
Deferred write shapes
Deferred write shapes, each reported with a pointer to the follow-up item: true procedures and scalar or void routines (jOOQ exposes them through a different call surface than table-valued functions), and the hop-less Mutation @routine whose return provides no re-read anchor — void, scalar, OUT-parameter binding, or a non-carrier Object. A chain whose first hop joins by condition: or carries a per-hop condition is likewise deferred: its predicate references the routine’s result, which must not appear in the follow-up query, so no re-read anchor can be derived.
Fetch forms and @splitQuery
A routine-backed child list rides the inline correlated multiset by default: one SQL statement, the lateral call re-evaluated per parent row. @splitQuery moves the field to the batched keyed re-query instead: the parent rows' bound columns are collected as DataLoader keys, sent as a VALUES table in one batch query, and the lateral call reads them off that table, so the routine still runs once per distinct input inside a single statement.
A child connection is always fetched in a query of its own, so @splitQuery is inferred there and not written; writing it draws the SPLIT_QUERY_REDUNDANT warning. Each parent pages its own rows within the one batch query:
type Actor @table(name: "actor") {
filmsConnection(minLength: Int!, filter: ActorFilmPageFilter, orderBy: ActorFilmOrderBy @orderBy): [ActorFilm!]
@asConnection(defaultFirstValue: 10)
@routine(name: "films_for_actor", argMapping: "pActorId: $source.actor_id, pMinLength: minLength")
@defaultOrder(fields: [{name: "film_id"}])
}
The @defaultOrder is needed because ActorFilm is bound to no table, so the function’s result has no primary key to fall back on, and the orderBy argument is nullable, so a client may leave it out.
Because the batch is keyed by the routine’s column-bound inputs, @splitQuery on an uncorrelated routine child (no parameter bound to a column) is rejected: there is nothing to key the batch on, and every parent would receive identical rows. Drop @splitQuery or bind a parent column. A child connection cannot drop the batch, so a routine child connection binding no parent column is refused as NO_KEY_FROM_PARENT, unless its path steps through a table before the routine; bind a parameter to a parent column with $source.<column>.
Constraints
-
Where the path ends on the routine, the return type needs no
@table: its rows are the routine’s result, which is no table binding (see The type’s rows are the routine’s result). Where it does carry@table, the hop from the routine’s result to that table is inferred, keyed by the table’s primary-key columns matched by name among the routine’s result columns, exactly as@reference(path: [{table: …}])written after the routine would be; a result exposing no such columns is the same build error the written hop gets, and the editor reports it at the@routineasGRAPHITRON_NO_ROUTE_TO_TARGET. This holds at root and child positions, on reads; aMutationfield’s routine is a write, whose return is re-read as described under Writes on Mutation. That covers a bare@routinefield and a path whose@referenceapplications all come before the routine, since hops written before it move where the path starts and never where it ends.@tablenaming the function fails the build asGRAPHITRON_TABLE_NAMES_ROUTINE. A return type that cannot hold a row (a scalar, an interface, a union) is rejected with@routine could not bind the return type … to its result table. -
Where the chain hops after the routine, the return type must be
@table-bound and the chain’s last node must be that table. The landing there is a catalog table, which is a table type in the schema in its own right, so its@tableis that type’s own binding rather than a second spelling of the routine’s name. A non-@tablereturn is rejected with@routine with @reference requires a @table-annotated return type, and the editor reports it at the field asGRAPHITRON_REFERENCE_WITHOUT_TARGET_TABLE: a@referencearrives only at a@table, a@routinebefore it included; a mismatch between the return and the landing is rejected with@routine could not be resolved — the field’s @table type … does not match the routine’s result table …. -
Without
@referenceon a Mutation field, the return may instead be a payload carrier (exactly one nullable@table-element data field plus an optional errors-shaped field). A carrier’s rows are not the routine’s result: they are what the data field re-reads post-commit, not what the field returns. The carrier +@referencecombination is rejected as a directive conflict, and@referenceon the carrier’s data field is deferred (see Writes on Mutation). -
name:must resolve to a table-valued function in the jOOQ catalog. A name that resolves to nothing is rejected with@routine could not be resolved — no table-valued function named …, and at a child position, where the routine is a step of the field’s path, the editor reports it at the@routineasGRAPHITRON_ELEMENT_UNRESOLVED; a name that resolves to a plain table or view is rejected with… resolves to a table or view, not a table-valued function. A name that exists as a database routine but is not table-valued (a procedure, or a scalar or void function) is reported as deferred with a pointer to the follow-up item carrying that call surface; only a genuinely absent name gets the unknown-name rejection. -
On a root field composing a chain (
QueryandMutationalike),@routinemust be the first directive application: a root chain has no implicit head, so the routine supplies it. A root routine’s parameters bind from GraphQL arguments only, no table standing there to read a column of. -
argMapping:parameter names are the jOOQ-generated (camelCased) names. Naming a parameter the routine does not declare is a build error, as is an entry that binds the parameter to nothing (see Where a parameter takes its value): a name that is no argument lists the field’s arguments, and points at$source.<column>where the name is a column; a$sourcecolumn the table lacks lists that table’s columns. A dot-path whose later segment names nothing the value at that depth opens into is a build error listing the candidates. A column has no path form, since it has no nested fields. -
An
argMappingpath must land on a scalar or enum leaf, or on a key column projected out of a node id (see Binding a parameter to a node id’s key column). Binding a routine parameter to a whole input object is a build error naming the input type: a routine IN parameter takes one value, so bind a scalar field inside it. Enum-valued and converted leaves are reported as deferred; the routine call emitter reads argument values directly today. A column-bound parameter’s Java type must match the routine parameter’s, and so must a key column projected out of a node id: a mismatch there is a build error naming both types, resolvable only where the routine’s call surface was captured. Resolving the parameter names off the generatedRoutinesmethod requires the consumer to compile their jOOQ sources with-parameters. -
A
@nodeId-carrying leaf’s@nodeIdmust nametypeName:explicitly, a routine parameter having no containing table to infer the node type from. Whether the leaf must be opened with a key column follows from the node type’s key: one column is inferred and the leaf may stay closed, and more than one is a build error stating the count and listing the columns, one binding carrying one value. The parameter receives a key column’s own value either way, never the encoded id. Naming a column the node type does not resolve is a build error suggesting the near miss, naming one whose Java type the parameter cannot take is a build error stating both types, and opening anIDthat carries no@nodeIdat all is a build error too: what a dot opens is a node id, and anIDthat is not one has nothing to open, so the editor reports the path at theargMappingasGRAPHITRON_ARGMAPPING_PATH_UNRESOLVED. A node id naming an interface or a union has a key per member, so opening one is a build error for now, naming each member’s key columns. Exactly one segment may follow a node id, a node id opening into one key column, and opening a list of node ids is reported as deferred: it names the list of that key column across the decoded ids, which routine parameter binding does not emit yet. A@serviceor@conditionparameter does take it, as aListof the column; see Projecting one key column. -
One routine node per chain: chains with more than one
@routineapplication do not generate yet and are reported as deferred. -
@orderBy,@conditionand@asConnectioncompose normally on a routine-backed read (see The read surface).@lookupKeycomposition is reported as deferred. On aMutationfield,@orderByand@conditionare reported as deferred (the write’s result shape has no filter or order surface to compose onto) and a Connection return is rejected. -
A routine child connection none of whose parameters is bound to a column of the parent row (
$source.<column>inargMapping) is refused asNO_KEY_FROM_PARENT, unless the path steps through a table before the routine: the connection is batched across parents, and the batch is keyed by what the routine reads off each parent.
See also
-
@referencecontributes the FK hops of the same chain and documents the directive-order contract. -
@tableis the plain catalog-driven counterpart for a field always backed by the same table. -
@serviceis the alternative when the developer supplies the entire fetcher rather than a routine-backed table.