validateFragmentDataStructure function

bool validateFragmentDataStructure({
  1. required DocumentNode document,
  2. required Map<String, dynamic>? data,
  3. String? fragmentName,
  4. Map<String, dynamic> variables = const {},
  5. bool addTypename = false,
  6. bool handleException = false,
})

Validates the structure of data against the fragment fragmentName in document.

Throws a PartialDataException if the data is invalid, unless handleException=true, in which case it returns false.

NOTE: while null data is a theoretically acceptable value for any fragment in isolation, we treat it as invalid here, maintaining consistency with denormalizeOperation.

Calls denormalizeFragment internally.

Implementation

bool validateFragmentDataStructure({
  required DocumentNode document,
  required Map<String, dynamic>? data,
  String? fragmentName,
  Map<String, dynamic> variables = const {},
  bool addTypename = false,
  bool handleException = false,
}) {
  return _validateSelectionSet(
    document: document,
    getSelectionSet: ({required document, required fragmentMap}) {
      return findFragmentInFragmentMap(
        fragmentMap: fragmentMap,
        fragmentName: fragmentName,
      ).selectionSet;
    },
    data: data,
    variables: variables,
    addTypename: addTypename,
    handleException: handleException,
  );
}