readFragment method
Map<String, dynamic> ?
readFragment(
- FragmentRequest fragmentRequest, {
- bool optimistic = true,
inherited
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.
Implementation
Map<String, dynamic>? readFragment(
FragmentRequest fragmentRequest, {
bool optimistic = true,
}) =>
denormalizeFragment(
// 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,
);