readFragment method

Map<String, dynamic>? readFragment(
  1. FragmentRequest fragmentRequest,
  2. {bool optimistic = true}

Reads a GraphQL fragment from any arbitrary id.

If there is more than one fragment in the provided document then a fragmentName must be provided to fragmentRequest.fragment to select the correct fragment.


Map<String, dynamic>? readFragment(
  FragmentRequest fragmentRequest, {
  bool optimistic = true,
}) =>
      // provided from cache
      read: (dataId) => readNormalized(dataId, optimistic: optimistic),
      typePolicies: typePolicies,
      dataIdFromObject: dataIdFromObject,
      returnPartialData: returnPartialData,
      addTypename: addTypename,
      // if there is partial data, we cannot read and return null
      handleException: true,
      // provided from request
      document: fragmentRequest.fragment.document,
      idFields: fragmentRequest.idFields,
      fragmentName: fragmentRequest.fragment.fragmentName,
      variables: sanitizeVariables(fragmentRequest.variables)!,
      possibleTypes: possibleTypes,