validateOperationDataStructure function

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

Validates the structure of data against the operation operationName in document.

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

Treats null data as invalid, thus distinguishing between valid data, and data which is simply not present as defined by the spec.

Calls denormalizeOperation internally.

Implementation

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