diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+AppSyncSigner.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+AppSyncSigner.swift index c0fb27d26a..17797d64e0 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+AppSyncSigner.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+AppSyncSigner.swift @@ -14,6 +14,15 @@ import AwsCommonRuntimeKit // CommonRuntimeKit.initialize() extension AWSCognitoAuthPlugin { + + /// Creates a AWS IAM SigV4 signer capable of signing AWS AppSync requests. + /// + /// **Note**. Although this method is static, **Amplify.Auth** is required to be configured with **AWSCognitoAuthPlugin** as + /// it depends on the credentials provider from Cognito through `Amplify.Auth.fetchAuthSession`. The static type allows + /// developers to simplify their callsite without having to access the method on the plugin instance. + /// + /// - Parameter region: The region of the AWS AppSync API + /// - Returns: A closure tha takes in a requestand returns a signed request. public static func createAppSyncSigner(region: String) -> ((URLRequest) async throws -> URLRequest) { return { request in try await signAppSyncRequest(request, diff --git a/AmplifyPlugins/Core/AWSPluginsCore/API/AWSAppSyncConfiguration.swift b/AmplifyPlugins/Core/AWSPluginsCore/API/AWSAppSyncConfiguration.swift index c83554c04d..e7d41af6d7 100644 --- a/AmplifyPlugins/Core/AWSPluginsCore/API/AWSAppSyncConfiguration.swift +++ b/AmplifyPlugins/Core/AWSPluginsCore/API/AWSAppSyncConfiguration.swift @@ -8,11 +8,25 @@ import Foundation @_spi(InternalAmplifyConfiguration) import Amplify + +/// Hold necessary AWS AppSync configuration values to interact with the AppSync API public struct AWSAppSyncConfiguration { + + /// The region of the AWS AppSync API public let region: String + + /// The endpoint of the AWS AppSync API public let endpoint: URL + + /// API key for API Key authentication. public let apiKey: String? + + /// Initializes an `AWSAppSyncConfiguration` instance using the provided AmplifyOutputs file. + /// AmplifyOutputs support multiple ways to read the `amplify_outputs.json` configuration file + /// + /// For example, `try AWSAppSyncConfiguraton(with: .amplifyOutputs)` will read the + /// `amplify_outputs.json` file from the main bundle. public init(with amplifyOutputs: AmplifyOutputs) throws { let resolvedConfiguration = try amplifyOutputs.resolveConfiguration() @@ -28,6 +42,5 @@ public struct AWSAppSyncConfiguration { } self.endpoint = endpoint self.apiKey = dataCategory.apiKey - } }