Skip to content

Documented auto-fetch of remaining fields from @service-returned records does not happen (RC30) #524

Description

@krhoybraten-sikt

Summary

The README ("Auto-fetching @table types from database") states that when a service
field returns a @table type, Graphitron automatically fetches all requested
fields using the primary key from the service result:

The service needs to return a record with the primary key populated, all other
fields on the record are fetched from the database. […] For listed fields,
Graphitron extracts primary keys from all service results and performs a single
batch query using WHERE pk IN (...).

On 10.0.0-RC30 this does not happen — non-PK fields resolve to null.

Reproduction

type Query {
  mineSynligeMiljoer: [Miljo]
      @service(service: {className: "…ApplikasjonsoversiktService", method: "mineSynligeMiljoer"})
}

type Miljo implements Node @table(name: "miljo") @node(typeId: "20014", keyColumns: ["MILJOKODE"]) {
  id: ID! @nodeId
  kode: String @field(name: "MILJOKODE")
  navn: String @field(name: "NAVN")
}
public List<MiljoRecord> mineSynligeMiljoer() {
    return ctx.select(MILJO.MILJOKODE).from(MILJO)
            .fetch(r -> { var rec = new MiljoRecord(); rec.setMiljokode(r.value1()); return rec; });
}

Query { mineSynligeMiljoer { kode navn } } returns
[{"kode":"demo","navn":null}, …]navn is never fetched even though the rows
exist with non-null values (verified directly in the database). The field is
plain (no @splitQuery), non-paginated, and the return type has @table — the
documented conditions for auto-fetch.

Workaround: the service selects complete records (ctx.selectFrom(MILJO))
instead of PK-only records. Fine for small tables; defeats the documented
pattern for large ones.

Version: 10.0.0-RC30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions