importsOfScalar function

Iterable<String> importsOfScalar(
  1. GeneratorOptions options,
  2. String type
)

Retrieve imports of a scalar map.

Implementation

Iterable<String> importsOfScalar(GeneratorOptions options, String type) {
  final scalarMapping = options.scalarMapping.firstWhere(
    (m) => m!.graphQLType == type,
    orElse: () => null,
  );

  final customParserImport = scalarMapping?.customParserImport;

  final result = List<String>.from(scalarMapping?.dartType?.imports ?? []);

  if (customParserImport != null) {
    result.add(customParserImport);
  }

  return result;
}