visitInlineFragmentNode method

  1. @override
void visitInlineFragmentNode(
  1. InlineFragmentNode node
)

Visit InlineFragmentNode.

Implementation

@override
void visitInlineFragmentNode(InlineFragmentNode node) {
  logFn(context, context.align + 1,
      '${context.path}: ... on ${node.typeCondition!.on.name.value}');
  final nextType = gql.getTypeByName(
      context.typeDefinitionNodeVisitor, node.typeCondition!.on);

  if (nextType.name.value == context.currentType!.name.value) {
    final visitor = GeneratorVisitor(
      context: context.nextTypeWithSamePath(
        nextType: nextType,
        nextClassName: null,
        nextFieldName: null,
        ofUnion: Nullable<TypeDefinitionNode?>(context.currentType),
        inputsClasses: [],
        fragments: [],
      ),
    );
    node.selectionSet.visitChildren(visitor);
  } else {
    final visitor = GeneratorVisitor(
      context: context.next(
        nextType: nextType,
        nextClassName: ClassName(name: nextType.name.value),
        nextFieldName: ClassPropertyName(name: nextType.name.value),
        ofUnion: Nullable<TypeDefinitionNode?>(context.currentType),
        inputsClasses: [],
        fragments: [],
      ),
    );
    node.visitChildren(visitor);
  }
}