coalesceErrors function

OperationException? coalesceErrors({
  1. List<GraphQLError>? graphqlErrors,
  2. LinkException? linkException,
  3. List? raw,
  4. OperationException? exception,
})

(graphqlErrors?, exception?) => exception?

merges both optional graphqlErrors and an optional container into a single optional container NOTE: NULL returns expected

Implementation

OperationException? coalesceErrors({
  List<GraphQLError>? graphqlErrors,
  LinkException? linkException,
  List<dynamic>? raw,
  OperationException? exception,
}) {
  if (exception != null ||
      linkException != null ||
      (graphqlErrors != null && graphqlErrors.isNotEmpty)) {
    return OperationException(
      linkException: linkException ?? exception?.linkException,
      raw: raw,
      graphqlErrors: [
        if (graphqlErrors != null) ...graphqlErrors,
        if (exception?.graphqlErrors != null) ...exception!.graphqlErrors
      ],
    );
  }
  return null;
}