如何在 iOS 客户端中传递 AWS AppSync 自定义请求 header?

How to pass AWS AppSync custom request header in iOS client?

AWS AppSync 支持从客户端传递自定义 headers 并使用 $context.request.headers[=21= 在您的 GraphQL 解析器中访问它们].
我想知道如何在 iOS 客户端中做到这一点?
谢谢 :)
https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html

我刚刚找到了一种在 iOS 客户端中传递额外 AWS AppSync 请求 Header 的方法:)
这是 [=11] 的示例 class =]

final class AppSyncManager {

    static func instance() -> AWSAppSyncClient {
        let tmpURL = URL(fileURLWithPath: NSTemporaryDirectory())
        let databaseURL = tmpURL.appendingPathComponent(databasName)
        let urlSessionConfiguration = URLSessionConfiguration.default
        // Our request header => In resolve mapping: $context.request.headers.author
        urlSessionConfiguration.httpAdditionalHeaders = ["author": CognitoUserPoolManager.instance.author]
        let appSyncConfig = try! AWSAppSyncClientConfiguration(url: endPointURL,
                                                               serviceRegion: region,
                                                               userPoolsAuthProvider: CognitoAuthProvider(),
                                                               urlSessionConfiguration: urlSessionConfiguration,
                                                               databaseURL: databaseURL)
        let appSyncClient = try! AWSAppSyncClient(appSyncConfig: appSyncConfig)
        appSyncClient.apolloClient?.cacheKeyForObject = { [=10=]["id"] }
        return appSyncClient
    }

}

在最新的 aws-mobile-appsync-sdk-ios SDK 2.6.22 中,问题正在修复。