Conventions for the code the generator emits; the reference companion to the "Generated code is a consumer artifact" axiom in Graphitron Development Principles.

Return types

DataFetchers return Result<Record> ; no DTOs, no TypeMappers. GraphQL-Java traverses records using the registered field DataFetchers. Exception: a connection field returns an instance of the class generated for its connection type in util.Connections, rendered from the store: the page’s records, its two page flags and its cursor function, with the count and facets as functions of the request where the type declares them. The connection’s and its edge’s fields are registered to that class’s members, and no other resolver stands between them and the page.

Every field in the schema is wired: the generated code registers a DataFetcher for each one and never leaves a field to graphql-java’s default PropertyDataFetcher (Alf, 2026-11-11). Where a field reads a member of the value it is handed, its registration names that member, so a member that is renamed or changes its signature fails the build or the classify-time check rather than resolving to null on a request. This holds for the values graphitron generates as much as for the consumer’s own classes.

A connection’s PageInfo is one generated class shared by every connection, and each facets type and facet value type has a generated class of its own, their fields registered like any other (Alf, 2026-11-11): what a connection hands its pageInfo and facets fields is an instance of one of them, never a map.

Selection-aware queries

DataFetchingFieldSelectionSet and SelectedField are threaded through all table method signatures, structurally committing to selection-aware queries:

  • Top-level queries: call Type.$project(SelectionOccurrences.ownFields(sel), table, env) for the column list (connectionNodes(sel) for a connection, whose unit fields sit at its node level), then dsl.select(fields).from(table)…​. Every grouped map holds the fields selected on the unit’s own type at its own level: a response key names a field only within its own selection set.

  • Inline nesting: use jOOQ multiset(select(columns).from(CHILD).where(…​)).as("alias") returning Field<?> (type-erased). Use type erasure at every helper method boundary ; jOOQ generic types compound badly with nesting depth, causing slow compile times.

  • Single child: the same multiset, with limit(1), never a row (Alf, 2026-11-15). jOOQ 3.19 passed a row to PostgreSQL as a row type, which came back with no field names; the single-row multiset keeps them. The unit’s shape otherwise stays as it is through the $project flip.

  • @splitQuery: separate DataLoader; parent fetches FK/PK columns, child batches by those keys.

Selection-driven queries produce different SQL per request, preventing cached query-plan reuse. This is an acceptable trade-off for wide tables with large optional columns; for narrow tables (≤ 10 columns) where most fields are always requested, TABLE.* is simpler and the dynamic-column overhead exceeds the benefit.

Error quality

BuildContext.candidateHint(attempt, candidates) sorts candidates by Levenshtein distance. The Levenshtein-suggestion contract has consolidated onto BuildContext and Rejection (the rejection-construction sites), with classifier-side callers thinning out as rejections are produced through the typed sealed-result path. When adding new jOOQ existence checks in the validator or builder, follow the same pattern ; pass the relevant candidate list from JooqCatalog to candidateHint, or produce the rejection through Rejection.unknownName(…​) so the candidate list rides on the typed result.

Column value binding: ColumnValues.fromWire, then DSL.val(value, col.getDataType())

When emitting code that binds a raw GraphQL input value (from an input map or env.getArgument(…​)) to a specific jOOQ column, coerce it at the column’s DataType through the generated ColumnValues.fromWire, and bind the result with the two-argument DSL.val:

DSL.val(ColumnValues.fromWire(table.COL.getDataType(), rawValue), table.COL.getDataType())

fromWire is the column’s own coercion, the one jOOQ applies, with ColumnValues.inRange asked first: a value inRange refuses is null, as is a value the coercion answers null for. Never hand a raw input value to jOOQ at a column’s type any other way. jOOQ converts wherever it is handed one, in DSL.val(rawValue, col.getDataType()) and in Record.fromArray alike, so each of those takes `fromWire’s result rather than the raw value, and a typed Java value for a method parameter is `fromWire’s result on its own.

Do not spell the call at the emit site. ColumnValuesRef.fromWire(outputPackage, dataType, value) mints it in render and emit, and ResolvedTableNames.fromWire(value, dataType) in the fetcher generator, so the coercion has one spelling.

Plain DSL.val(value, col.getDataType()) on its own remains the bind for a value the server produced: a parent’s key, a slot of a decoded node id (which ColumnValues.exact already read), a build-time constant.

Do not use the one-argument form with a Java-side cast (DSL.val((JavaType) rawValue)):

  • GraphQL-Java delivers enum values as String ; a Java cast to the jOOQ enum class throws ClassCastException at runtime.

  • GraphQL-Java delivers ID scalars as String ; a cast to Long (or any numeric PK type) also throws.

  • The one-argument form ignores the column’s registered jOOQ Converter entirely.

Coercing at the column’s DataType hands rawValue to that type and its registered Converter. No SQL CAST is rendered; the coercion is purely Java-side, inside jOOQ. The one deliberate exception is a connection cursor’s element for a column the database writes, which is not GraphQL input but the database’s own text handed back to it, and binds as a cast to the column’s type (see "Cursor encode/decode").

CallSiteExtraction solves a different problem. Its value-coercion strategies exist to produce a typed Java value for a condition/ordering method parameter ; code paths where a developer-written method expects the column’s Java type, not a jOOQ Field<T>. For inline jOOQ DSL expressions (INSERT values(…​), UPDATE set(…​), DELETE/UPDATE where(…​) predicates), fromWire at the column’s DataType does the coercion through jOOQ with no further Java-side step, and no CallSiteExtraction switch is needed.

Precedent: LookupRows.slotValueExpr, whose plain and composite slots go through ColumnValuesRef.fromWire.

For DTO-parent batching ; where the parent’s backing class is a plain POJO or Java record without a jOOQ FK to the child’s @table ; see DTO-parent batching below; a typed record accessor on the parent’s class is how the framework gets a typed key when the catalog can’t supply one.

Column-to-column comparison: ColumnComparison

The companion rule to the one above, on the other axis. Where ColumnValues.fromWire and DSL.val(value, col.getDataType()) cover "bind a value against a column", every comparison of two catalog columns goes through no.sikt.graphitron.render.ColumnComparison and none is spelled inline.

The reason is that the two columns can disagree on their Java type while agreeing on their SQL type. A jOOQ Converter is a client-side type mapping only: it changes what Field.getType() reports and cannot change the column’s SQL type. A consumer whose codegen selects a <forcedType> by column path rather than by type therefore lands the converter on one end of a foreign key and not the other, and the two ends diverge: one stays Field<Short> while the other becomes Field<String>. a.eq(b) then does not compile, and the whole generated module fails with it, even though a = b was always a valid, index-usable predicate.

ColumnComparison reconciles that with coerce, which reinterprets a field’s Java type and leaves the rendered SQL alone. Reach for it, never for cast: cast puts a real SQL CAST around the column and costs the index on it.

Entry point When the right operand is

equality

another aliased table column. Overloaded for the walk’s ColumnRef and for two column expressions whose types a store-sourced reader decoded from captured names.

equalityAgainstField

some other Field expression typed by a known catalog column, typically a parentInput.field(…) lookup into a VALUES-derived table. The caller names the column the lookup’s DataType was spelled from.

equalityAgainstValue

a bare Java value, so there is nothing for coerce to attach to. This is the two rules composed: bind the value at the DataType of the column it was read from, which makes it a Field rendering through that column’s converter, then coerce that field onto the receiver.

Two properties are worth knowing before touching a call site. A pair whose types agree, or either of whose types is unknown, emits left.eq(right) unchanged, so no approved generated output moves for a schema that compiles today. And the argument is coerced onto the receiver in both directions: neither "raw" nor "referenced" is recoverable from a TypeName, and since neither operand is a bind value the direction is invisible in the emitted SQL, so the rule is chosen for mechanical reviewability rather than for semantics.

A .onKey(Keys.<CONSTANT>) join needs none of this: it names a catalog constant and is type-blind by construction. So is any comparison whose two operands take their type from the same ColumnRef, which is most of the generator’s eq sites and the reason the mint has as few callers as it does.

DTO-parent batching

When a record-backed parent’s backing class (reflected from its producer) is not a jOOQ TableRecord, the catalog cannot supply the FK columns the column-keyed DataLoader path needs to batch a child @table field. The parent’s class closes that gap itself: a typed zero-arg accessor returning the child table’s record (or a collection of them) is the key’s source. The classifier reflects on the accessor once at build time and produces a KeyLift.Accessor(AccessorRef, Arity) verdict. The residue SourceKey derives its Wrap.Record from that lift arm, and the correlation is a ParentCorrelation.OnLiftedSlots over the target’s primary key (target table + column tuple, single-hop by construction), so the DataLoader key tuple is the target-column tuple as a type fact. The emitter feeds that into the existing SplitRowsMethodEmitter.buildListMethod path with no identity branching: target accessors come from ParentCorrelation.OnLiftedSlots.columns(), key extraction from the accessor call. The parent’s class is the single place where the DTO to key mapping lives; a parent that carries only a key’s value carries a record with just its primary key set.

Helper-locality

Emitted helper methods that bind column references to a specific aliased jOOQ Table instance always take the Table as a parameter ; never declare it locally. Callers from different paths (root fetcher, inline subquery, Split-rows method) need to pass distinct aliases for the same target table; a locally-declared Table forces the wrong alias on every caller but the one the helper was first written for.

Pattern (canonical example, <fieldName>OrderBy emitted by TypeFetcherGenerator.buildOrderByHelperMethod):

private static OrderByResult <fieldName>OrderBy(DataFetchingEnvironment env, <Table> table) { ... }

Each call site supplies the alias appropriate to its scope: the root fetcher passes its declared <entity>Table; a Split-rows method passes its FK-chain terminal alias; an inline subquery passes its correlated alias. The helper’s column references resolve through the parameter.

The rule does not apply to helpers that are not Table-bound (e.g. cursor encode/decode helpers operating on Field<?> / SortField<?>).

Cursor encode/decode

The emitter companion to the "Model metadata over parallel type systems" principle: each cursor column’s jOOQ DataType is already known, so cursor round-tripping goes through the column metadata rather than a hand-rolled type-tag system (i:, s:, l:).

  • Who writes an element: ColumnValues.writtenByDatabase(field.getDataType()), the one place it is decided, read at runtime off the column’s DataType so a method: sort key is answered like a column. Java writes and reads a column whose Java reading is exact: the forms Graphitron 9 issued (numeric, boolean, date, timestamp, timestamp with time zone) and the types whose Java value and text are the database’s (character, uuid, enum). The database writes and reads every other column, one with no SQL type among them, so a type nobody listed is carried exactly rather than approximately: an infinity bound, a fraction of a second, an array or a type jOOQ cannot read is never held in Java.

  • Encode a seek value Java writes: the column’s database value, the record’s value passed through the column’s Converter.to (jOOQ’s identity converter when it has none; an EnumType as its literal), written by ColumnValues.toText from the column’s SQL DataType: numeric bare, boolean bare, temporal in Oracle’s JSON_ARRAY form, everything else a JSON string. Never the user value’s text: a converter’s user type need not share its text with the database type.

  • Encode a seek value the database writes: the text the page selected beside the row, cast(column as varchar) under the position’s alias (ConnectionHelper.cursorTexts, which pageRequest adds to the select list in place of the column itself), as a JSON string. A record without the alias is an emitter fault and fails loudly; there is no fallback to the Java reading.

  • Decode a seek value: ColumnValues.fromDatabase(field.getDataType(), element), which parses the element as the database type (getSQLDataType().convert) and runs Converter.from. Not the converted field.getDataType().convert(element): it answers null for text the user type does not share with the database type, and hands an input that is already a user-type instance back unconverted. A release-candidate cursor, the format the Graphitron 10 release candidates wrote and the decoder still reads, is the one exception: its token is the user value’s toString(), so it is coerced on the converted type with DSL.val(token, field.getDataType()).getValue(), the one place the decoder deliberately reads through the converted type, reproducing what those releases read. Its tokens stay Java’s for every column: a token those releases could not page from stays the client’s error rather than becoming the database’s.

  • Decode a seek value the database writes: cast(? as <the column’s type>) over the element’s text, so the database reads back the value it wrote. A JSON number is read as its text; a JSON boolean, which no such element is, is refused.

  • Where the encoded value comes from: the order column’s value on the edge’s own record, which need not be the expression the seek compared. On a multi-table connection the seek compares the pages union’s column, while the edge is the participant’s stage-2 record, re-projecting its own key and slot columns under the union’s aliases, and casting the text of each column the database writes from the participant’s own column (cursorTexts(extraFields, sources), the sources looked up by the order columns' names in the one map that drives the re-projection). The classifier’s agreement rules, which type each union column by its first participant’s column, are what make the two one value of one type, and no stronger invariant is held (Filip, 2026-11-16). A cursor is still computed from the element and the ordering, never from the element’s place in the page.

  • A refused element: a cursor the decoder can check itself (its Base64, its JSON shape, its arity, an element Java parses) is refused as the client’s error. Where only the database can tell whether an element is a value of its column, as for a column whose value Java does not hold exactly, the database checks it when it runs the page query, and its refusal stays a server-classified error: the decoder spends no round trip asking first, and a data exception from the query is not reclassified as the client’s, which would also blame the client for a data fault in a condition or a filter (Filip, 2026-11-16).

  • The no-seek case: DSL.noField(field) where a column position must be present but no seek value applies, rather than a null placeholder or an omitted column that would misalign the tuple.

OrderByResult (pairing List<SortField<?>> with List<Field<?>>) is the carrier these operate over.