buildDataLibrary function
Library
buildDataLibrary(
- SourceNode docSource,
- SourceNode schemaSource,
- String partUrl,
- Map<
String, Reference> typeOverrides, [ - InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig = const InlineFragmentSpreadWhenExtensionConfig(generateWhenExtensionMethod: false, generateMaybeWhenExtensionMethod: false),
- DataClassConfig dataClassConfig = const DataClassConfig(reuseFragments: false),
Implementation
Library buildDataLibrary(
SourceNode docSource,
SourceNode schemaSource,
String partUrl,
Map<String, Reference> typeOverrides, [
InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig =
const InlineFragmentSpreadWhenExtensionConfig(
generateWhenExtensionMethod: false,
generateMaybeWhenExtensionMethod: false,
),
DataClassConfig dataClassConfig = const DataClassConfig(
reuseFragments: false,
),
]) {
final fragmentMap = _fragmentMap(docSource);
final dataClassAliasMap = dataClassConfig.reuseFragments
? _dataClassAliasMap(docSource, fragmentMap)
: <String, Reference>{};
final operationDataClasses = docSource.document.definitions
.whereType<OperationDefinitionNode>()
.expand(
(op) => buildOperationDataClasses(
op,
docSource,
schemaSource,
typeOverrides,
whenExtensionConfig,
fragmentMap,
dataClassAliasMap,
),
)
.toList();
final fragmentDataClasses = docSource.document.definitions
.whereType<FragmentDefinitionNode>()
.expand(
(frag) => buildFragmentDataClasses(
frag,
docSource,
schemaSource,
typeOverrides,
whenExtensionConfig,
fragmentMap,
dataClassAliasMap,
),
)
.toList();
return Library(
(b) => b
..directives.add(Directive.part(partUrl))
..body = ListBuilder(<Spec>[
...operationDataClasses,
...fragmentDataClasses,
]),
);
}