readQuery<TData, TVars> method Null safety

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

Reads denormalized data from the Cache for the given operation.

Implementation

TData? readQuery<TData, TVars>(
  OperationRequest<TData, TVars> request, {
  bool optimistic = true,
}) {
  final json = denormalizeOperation(
    read: optimistic ? optimisticReader : (dataId) => store.get(dataId),
    document: request.operation.document,
    addTypename: addTypename,
    operationName: request.operation.operationName,
    // TODO: don't cast to dynamic
    variables: (request.vars as dynamic)?.toJson(),
    typePolicies: typePolicies,
    dataIdFromObject: dataIdFromObject,
    possibleTypes: possibleTypes,
  );
  return json == null ? null : request.parseData(json);
}