inlineFragment static method

InlineFragmentNode inlineFragment(
  1. String typeName, {
  2. List<SelectionNode>? selections,
})

Creates an InlineFragmentNode for type-specific selections.

This helper simplifies the creation of inline fragments that apply selections conditionally based on the concrete type.

Example:

inlineFragment('User', selections: [
  field('name'),
  field('email'),
])  // ... on User { name email }

Implementation

static InlineFragmentNode inlineFragment(
  String typeName, {
  List<SelectionNode>? selections,
}) {
  return InlineFragmentNode(
    typeCondition: TypeConditionNode(
      on: NamedTypeNode(name: nameNode(typeName)),
    ),
    selectionSet: SelectionSetNode(selections: selections ?? []),
  );
}