fragmentsFromDocument function

Map<String, FragmentDefinitionNode> fragmentsFromDocument(
  1. DocumentNode document
)

Implementation

Map<String, FragmentDefinitionNode> fragmentsFromDocument(
  DocumentNode document,
) {
  final allFragments = document.definitions.whereType<FragmentDefinitionNode>();
  return Map.fromEntries(
    allFragments.map((e) => MapEntry(e.name.value, e)),
  );
}