readFragment<TData, TVars> method Null safety

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,
    // TODO: don't cast to dynamic
    variables: (request.vars as dynamic)?.toJson(),
    typePolicies: typePolicies,
    addTypename: addTypename,
    dataIdFromObject: dataIdFromObject,
    possibleTypes: possibleTypes,
  );
  return json == null ? null : request.parseData(json);
}