Commit a7ed7b5204

a7ed7b5204f6be18ab4048710d82ae351a073aa9

parent: ebdb38ad9b

Unsigned

cmc <hello@cleberg.net> · 2026-03-24 21:49 UTC

fix: route executeGraphQLRequest through SRHTClient instead of URLSession.shared

Layout: unified · split

Hutch/Views/Inbox/ThreadViewModel.swift +5 −29
@@ -684,36 +684,12 @@ final class ThreadViewModel {
684684 query: String,
685685 variables: [String: any Sendable]
686686 ) async throws -> T {
687 guard let token = KeychainHelper.loadToken(), !token.isEmpty else {
688 throw SRHTError.unauthorized
689 }
690
691 var request = URLRequest(url: SRHTService.lists.url)
692 request.httpMethod = "POST"
693 request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization")
694 request.setValue("application/json", forHTTPHeaderField: "Content-Type")
695
696 let encoder = JSONEncoder()
697 request.httpBody = try encoder.encode(
698 GraphQLRequestBody(
699 query: query,
700 variables: variables.mapValues { AnyCodable($0) }
701 )
687 try await client.execute(
688 service: .lists,
689 query: query,
690 variables: variables,
691 responseType: T.self
702692 )
703
704 let (data, _) = try await URLSession.shared.data(for: request)
705 let decoder = JSONDecoder()
706 decoder.dateDecodingStrategy = .srhtFlexible
707 let envelope = try decoder.decode(GraphQLResponse<T>.self, from: data)
708 if let errors = envelope.errors, !errors.isEmpty {
709 throw SRHTError.graphQLErrors(errors)
710 }
711 guard let payload = envelope.data else {
712 throw SRHTError.decodingError(
713 DecodingError.dataCorrupted(.init(codingPath: [], debugDescription: "No data in thread detail response"))
714 )
715 }
716 return payload
717693 }
718694
719695 private static func isRecoverableNoRows(_ error: Error) -> Bool {