Selection class
A node in a selection tree.
The tree mirrors the shape of a GraphQL operation: every node is a field (with optional arguments) and its children are the sub-selection. Lists are transparent — a list field has the element's fields as children.
The alias is derived from the field name and a stable hash of the arguments so that the same field queried with different arguments can live side by side in one document and in the cache.
Constructors
- Selection.root(String operation)
Properties
- alias → String
-
Also the cache key for this field on its parent object. Inline
fragments use
... on Type, which no field alias can spell.final -
aliasPath
→ List<
String> -
Aliases from the root (exclusive) down to this node (inclusive).
no setter
-
args
→ Map<
String, Arg> -
final
-
childAliases
→ Set<
String> -
Aliases of the direct children (top-level fields for a root).
no setter
-
children
→ Iterable<
Selection> -
no setter
- field → String
-
The field name; for an inline fragment, the type condition.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFragment → bool
-
no setter
- isLeaf → bool
-
no setter
- isObject ↔ bool
-
Set when the field was accessed as an object or list of objects. Such a
node must be printed with braces even if no sub-field was read yet.
getter/setter pair
- isRoot → bool
-
no setter
- keyField ↔ String?
-
Set when the object type is normalizable: this field (
id) is always printed alongside__typenameso the response can be keyed.getter/setter pair - parent → Selection?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- typeCondition → String?
-
Set on an inline fragment node (
... on Launch { … }): its children are fields of that concrete type, read at the parent's cache location. A fragment adds nothing to cache paths (aliasPath skips it).final
Methods
-
child(
String field, [Map< String, Arg> args = const {}]) → Selection -
childByAlias(
String alias) → Selection? -
covers(
Selection other) → bool -
True if every leaf of
otheris present in this tree. -
ensurePath(
Selection other) → Selection -
Ensures every node of
other's path from its root exists under this root, and returns the corresponding node in this tree. -
fragment(
String typename, [String? keyField]) → Selection -
The inline fragment
... on [typename]under this (abstract-typed) object node.keyFieldas in objectChild, for keyed member types. -
mergeFrom(
Selection other) → void -
Deep-merges
other's subtree into this node. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
objectChild(
String field, [Map< String, Arg> args = const {}, String? keyField]) → Selection -
Like child, flagged as an object selection.
keyFieldmarks the object as an entity whose key field must always be fetched. -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited