load static method
Loads configPath from root; root/pubspec.yaml supplies the
package name.
Implementation
static GraphQLGenConfig load({
String root = '.',
String configPath = defaultPath,
}) {
final pubspec = File(p.join(root, 'pubspec.yaml'));
if (!pubspec.existsSync()) {
throw StateError('No pubspec.yaml in ${p.absolute(root)}.');
}
final packageName =
(loadYaml(pubspec.readAsStringSync()) as YamlMap)['name'] as String;
final file = File(p.join(root, configPath));
if (!file.existsSync()) {
throw StateError('No $configPath found. Run `init` to create one.');
}
final yaml = loadYaml(file.readAsStringSync());
return fromYaml(
yaml is YamlMap ? yaml : YamlMap(),
packageName: packageName,
);
}