when<T> method
T
when<T>({
- required T field(),
- required T fragmentSpread(
- FragmentSpreadNode
- required T inlineFragment(
- InlineFragmentNode
Implementation
T when<T>({
required T Function(FieldNode) field,
required T Function(FragmentSpreadNode) fragmentSpread,
required T Function(InlineFragmentNode) inlineFragment,
}) {
final selection = this;
if (selection is FieldNode) return field(selection);
if (selection is FragmentSpreadNode) return fragmentSpread(selection);
if (selection is InlineFragmentNode) return inlineFragment(selection);
throw Error();
}