getSingleScalarMap function

ScalarMap? getSingleScalarMap(
  1. GeneratorOptions options,
  2. String type, {
  3. bool throwOnNotFound = true,
})

Retrieve a scalar mapping of a type.

Implementation

ScalarMap? getSingleScalarMap(GeneratorOptions options, String type,
    {bool throwOnNotFound = true}) {
  final scalarMap =
      options.scalarMapping.followedBy(_defaultScalarMapping.values).firstWhere(
            (m) => m!.graphQLType == type,
            orElse: () => null,
          );

  if (throwOnNotFound && scalarMap == null) {
    throw MissingScalarConfigurationException(type);
  }

  return scalarMap;
}