Skip to content

@orderBy/@defaultOrder silently ignored on multitable interface queries #523

Description

@krhoybraten-sikt

Summary

On a Query field returning a multitable interface (implementations spread across
tables), both @defaultOrder on the field and a user-supplied @orderBy input
compile without errors but have no effect at runtime — results always come back
in primary-key order.

type Query {
  applikasjoner(
    filter: ApplikasjonerFilterInput
    orderBy: ApplikasjonerOrderByInput @orderBy
  ): [Applikasjon] @asConnection(defaultFirstValue: 100) @defaultOrder(fields: [{name: "NAVN"}])
}

input ApplikasjonerOrderByInput {
  direction: OrderDirection!
  orderByField: ApplikasjonerOrderByField!
}

enum ApplikasjonerOrderByField {
  NAVN @order(fields: [{name: "NAVN"}])
}

Applikasjon is a multitable interface with three implementing @table types
(feide_applikasjon, maskinporten_applikasjon, maskinbruker_applikasjon);
all three tables have the NAVN column.

Version: 10.0.0-RC30

Expected behaviour

Either results ordered by NAVN (default @defaultOrder, overridable by the
orderBy input) — or, if multitable ordering is unsupported, an author-error at
generate time
like the one @condition-overloads produce, so the schema author
finds out at build time rather than the client at runtime.

Actual behaviour

Codegen succeeds. At runtime orderBy: {direction: ASC, orderByField: NAVN} and
orderBy: {direction: DESC, orderByField: NAVN} return identical results in
primary-key order:

ASC:  fs.sikt.no (test), FS Admin (test), Min kompetanse (test), rasbruker_7778
DESC: fs.sikt.no (test), FS Admin (test), Min kompetanse (test), rasbruker_7778
      (subjekt_id -23, -22, -21, -16 — i.e. PK ascending)

(Observed via Apollo Router against the subgraph; same behaviour without the
router. Filters via @condition on the same query work correctly, so the input
reaches the generated query — only the ordering is dropped.)

Notes

  • Documentation ("Sorting", "Polymorphic queries") does not state a multitable
    limitation for @orderBy/@defaultOrder; the @condition section explicitly
    covers multitable, which suggests ordering was simply not wired up for the
    multitable code path.
  • Workaround used meanwhile: client-side sorting of each fetched page (imperfect
    across pagination) in fs-admin.

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