Remote / foldkit-remote/why

QueryExplanation

interface · packages/remote/src/why.ts:61

interface QueryExplanation {
  readonly domain: string
  readonly query: string
  readonly input: unknown
  readonly identity: string
  readonly window: QueryWindow
  readonly select: RelationRequirement
  readonly body?: string | undefined
  readonly dependencies?: ExplainedDependencies | undefined
  readonly state: RemoteData<unknown>['_tag']
  readonly surfaces?: ReadonlyArray<string> | undefined
  readonly activation?:
    | ReadonlyArray<{
        readonly surface: string
        readonly path: readonly string[]
        readonly tag: string
      }>
    | undefined
}

What one query read is, and what it currently is — data-query-DESIGN §29.1.

Every member is gathered from something that already existed: the read was always this many pieces, and nothing had ever been asked to put them in one place. It is plain serializable data, so a DevTools panel, a log line and a test assert on the same value.

Two members of §29.1's sketch are not here, and their absence is the finding rather than an omission:

  • Surface. A Projection does not know which Surface reads it, and often several do — so it is not a property of the read, and explain cannot recover it alone. Given the active Surfaces (the same record subscriptions takes), it reports every Surface reading the connection rather than guessing one, and omits the member entirely when it was not given them.
  • Executor. The thing that answers a query is a RemoteClient Layer in the runtime, not a value in the Model, and a pure read of the Model cannot see it. That is the same boundary that makes this function pure and replayable, so it is worth more than the line of text.

And one that the design proposed and this does not want: expectation (required versus optional). §11 left it unbuilt for want of a consumer, and the explanation was the likeliest consumer. It turns out not to need it — a query's result is a connection, so the shape is a Page, decided by the definition rather than by the read. Nothing here has an opinion about whether an empty one is an error, because nothing here has to have one.

Members

QueryExplanation.domain

property · packages/remote/src/why.ts:63

readonly domain: string

The bound Remote domain that answers it.

QueryExplanation.query

property · packages/remote/src/why.ts:65

readonly query: string

The definition's name.

QueryExplanation.input

property · packages/remote/src/why.ts:67

readonly input: unknown

The input as encoded, which is what the identity is built from.

QueryExplanation.identity

property · packages/remote/src/why.ts:69

readonly identity: string

The connection identity: definition plus canonical input, excluding the window.

QueryExplanation.window

property · packages/remote/src/why.ts:71

readonly window: QueryWindow

How much of the connection this read asks for.

QueryExplanation.select

property · packages/remote/src/why.ts:73

readonly select: RelationRequirement

What it reads of each item, as the slice asked of the server.

QueryExplanation.body

property · packages/remote/src/why.ts:79

readonly body?: string | undefined

What the query means, as readable text — Query.show, and so neither SQL nor whatever the backend compiled. Absent for a definition made with Query.make, whose meaning lives on the server that answers it.

QueryExplanation.dependencies

property · packages/remote/src/why.ts:85

readonly dependencies?: ExplainedDependencies | undefined

The fields, inputs and operations the body reads; absent with the body. Plain data, so it serializes: a field is its Entity's name and key, which is unambiguous because a query reads one Entity.

QueryExplanation.state

property · packages/remote/src/why.ts:87

readonly state: RemoteData<unknown>['_tag']

What the read answers from this Model right now.

QueryExplanation.surfaces

property · packages/remote/src/why.ts:93

readonly surfaces?: ReadonlyArray<string> | undefined

The active Surfaces reading this connection at this Model, if the active record was supplied. Plural because several may, which is why a Projection cannot carry the answer itself.

QueryExplanation.activation

property · packages/remote/src/why.ts:99

readonly activation?:
  | ReadonlyArray<{
      readonly surface: string
      readonly path: readonly string[]
      readonly tag: string
    }>
  | undefined

Why each of those Surfaces is active, where it was placed with Surface.when — the Model path and the tag, without running anything. A Surface placed with Surface.at has no entry: a callback cannot be read.