-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Convert Swift extension to helper class for use by ObjC
- Loading branch information
Max Chuquimia
committed
May 13, 2024
1 parent
6ec751f
commit a162771
Showing
6 changed files
with
38 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import Foundation | ||
|
||
@objcMembers | ||
public class URLSessionTaskHelper: NSObject { | ||
|
||
static func getGraphQLOperationName(from task: URLSessionTask?) -> String? { | ||
guard let task = task else { return nil } | ||
guard task.originalRequest?.value(forHTTPHeaderField: "Content-Type") == "application/json" else { return nil } | ||
guard let requestBody = task.originalRequest?.httpBody else { return nil } | ||
|
||
let requestInfo = try? JSONDecoder().decode(GraphQLRequest.self, from: requestBody) | ||
|
||
return requestInfo?.operationName | ||
} | ||
|
||
} | ||
|
||
private struct GraphQLRequest: Decodable { | ||
let operationName: String | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters