Accessor class abstract

Base class for all generated schema types.

A generated type is a thin, allocation-cheap view over a location in the cache: (selection node, cache path). Every getter records the field on the selection tree, then reads the value at path + field from the cache.

Typed getters are generated from the schema, so there is no dynamic dispatch and everything is tree-shakeable — this is what replaces JS Proxy in GQty.

Constructors

Accessor(Recorder recorder, Selection selection, List<Object> path)

Properties

$typename → String?
The __typename of the cached object, if any.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isSkeleton → bool
True when this object does not exist in cache yet (skeleton state): every scalar read returns null and records a miss.
no setter
path → List<Object>
This object's location in the cache: aliases and list indices, walked from the operation root — or from an entity when the first element is a Ref (see lookup on object).
final
recorder → Recorder
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selection → Selection
This object's node in the selection tree.
final

Methods

enumList<T>(String field, T parse(String), {Map<String, Arg>? args}) → List<T?>?
Reads a list of enums, mapping each wire String through parse. Same miss/skeleton semantics as scalarList.
enumValue<T>(String field, T parse(String), {Map<String, Arg>? args}) → T?
Reads an enum field: the cached wire String mapped through parse (the generated fromGraphQL). Same miss/skeleton semantics as scalar.
isFetched(String field, {Map<String, Arg>? args}) → bool
True when the cache holds a value for field on this object — including an explicit server null — false when it was never fetched. This is the per-field counterpart to QueryState.hasMissingData: use it to tell "not fetched yet" apart from "the server said null" for one field, without branching the whole widget on isSkeleton.
list<R extends Accessor>(String field, R ctor(Recorder, Selection, List<Object>), {Map<String, Arg>? args, bool keyed = false}) → List<R>?
Reads a list of objects. Skeleton lists contain a single skeleton element so list.map((e) => e.name) still records the element selection.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
object<R extends Accessor>(String field, R ctor(Recorder, Selection, List<Object>), {Map<String, Arg>? args, bool keyed = false, String? lookup}) → R?
Reads an object field. Returns a skeleton accessor when not cached, null only when the server explicitly returned null.
on<R extends Accessor>(String typename, R ctor(Recorder, Selection, List<Object>), {bool keyed = false}) → R?
Views this object as the concrete type typename (the inline fragment ... on Typename): fields read through the result are selected inside that fragment and read at this object's cache location.
scalar<T>(String field, {Map<String, Arg>? args}) → T?
Reads a scalar field. Returns null (and records a miss) when not cached.
scalarAs<T, W>(String field, T parse(W), {Map<String, Arg>? args}) → T?
Reads a scalar field whose wire form (type W, read via scalar — usually String) is converted to a richer Dart type T by parse. Backs both enumValue and a generator --scalar mapping (e.g. DateTime). Same miss/skeleton semantics as scalar.
scalarList<T>(String field, {Map<String, Arg>? args}) → List<T?>?
Reads a list of scalars. Skeleton lists contain a single null.
scalarListAs<T, W>(String field, T parse(W), {Map<String, Arg>? args}) → List<T?>?
Reads a list of such values (see scalarAs). Same miss/skeleton semantics as scalarList.
toString() → String
A string representation of this object.
override
whenType<T>(Map<String, T Function()> cases, {T orElse()?}) → T?
Runs the branch of cases for this object's __typename, orElse for a type without a branch (e.g. one added to the schema later), null when neither applies. Backs the generated when(...).
write(String field, Object? value) → void

Operators

operator ==(Object other) → bool
The equality operator.
inherited