Skip to content

Conversation

dconeybe
Copy link
Collaborator

@dconeybe dconeybe commented Feb 27, 2025

Adds support for GQL partial errors.

This change also refactors the base DataConnectError class to be a protocol and specific errors to be structs that implement this protocol.

do {
      _ = try await DataConnect.kitchenSinkConnector.deleteOrder.execute(id: id)
    } catch let dcError as DataConnectOperationError {
      guard let response = dcError.response,
       let data = response.data(asType: DeleteOrderMutation.Data.self) else {
        throw dcError
      }
      // handle partially decoded data
      
      // access json data
      let json = response.rawJsonData
    }

Refactored Error Types

do { 


} catch let initError as DataConnectInitError { 
   // handle err
} catch let codecError as DataConnectCodecError where codecError.code == .invalidUUID {
   // handle invalid uuid err
} 

@dconeybe dconeybe self-assigned this Feb 27, 2025
@aashishpatil-g aashishpatil-g changed the title DO NOT MERGE: partial errors wip [WIP]: Partial Errors Implementation Mar 21, 2025
@aashishpatil-g aashishpatil-g self-assigned this Mar 26, 2025
AnyDataConnectError just becomes a container of DataConnectError so it can contain both base and domain errors
@aashishpatil-g aashishpatil-g changed the title [WIP]: Partial Errors Implementation Partial Errors Implementation Mar 26, 2025
Copy link
Member

@ncooke3 ncooke3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly documentation improvements to which I left suggestions to make it easier to address. I also had two impl. questions in GrpcClient.swift.