readFragment<TData, TVars> method

TData? readFragment<TData, TVars>(
  1. FragmentRequest<TData, TVars> request,
  2. {bool optimistic = true}
)

Reads denormalized data from the Cache for the given fragment.

Implementation

TData? readFragment<TData, TVars>(
  FragmentRequest<TData, TVars> request, {
  bool optimistic = true,
}) {
  final json = denormalizeFragment(
    read: optimistic ? optimisticReader : (dataId) => store.get(dataId),
    document: request.document,
    idFields: request.idFields,
    fragmentName: request.fragmentName,
    variables: request.varsToJson(),
    typePolicies: typePolicies,
    addTypename: addTypename,
    dataIdFromObject: dataIdFromObject,
    possibleTypes: possibleTypes,
    allowDanglingReference: true,
  );
  return json == null ? null : request.parseData(json);
}