Skip to content

Commit 507f30d

Browse files
authored
chore: kickoff release
2 parents a86dc2e + 84c1cc1 commit 507f30d

File tree

15 files changed

+223
-62
lines changed

15 files changed

+223
-62
lines changed

.github/workflows/deploy_package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ jobs:
6666
token: ${{steps.retrieve-token.outputs.token}}
6767

6868
- name: Setup Ruby
69-
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
69+
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0
7070
with:
7171
ruby-version: '3.2.1'
7272
bundler-cache: true

.github/workflows/deploy_release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
token: ${{steps.retrieve-token.outputs.token}}
6363

6464
- name: Setup Ruby
65-
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
65+
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0
6666
with:
6767
ruby-version: '3.2.1'
6868
bundler-cache: true

.github/workflows/deploy_unstable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ jobs:
6262
token: ${{steps.retrieve-token.outputs.token}}
6363

6464
- name: Setup Ruby
65-
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
65+
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0
6666
with:
6767
ruby-version: '3.2.1'
6868
bundler-cache: true

.github/workflows/release_doc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
token: ${{steps.retrieve-token.outputs.token}}
3737

3838
- name: Setup Ruby
39-
uses: ruby/setup-ruby@250fcd6a742febb1123a77a841497ccaa8b9e939 # v1.152.0
39+
uses: ruby/setup-ruby@22fdc77bf4148f810455b226c90fb81b5cbc00a7 # v1.171.0
4040
with:
4141
ruby-version: '3.2.1'
4242
bundler-cache: true

Amplify/Categories/API/Request/GraphQLOperationRequest.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public struct GraphQLOperationRequest<R: Decodable>: AmplifyOperationRequest {
2525
/// The path to traverse before decoding to `responseType`.
2626
public let decodePath: String?
2727

28+
/// The authorization mode
29+
public let authMode: AuthorizationMode?
30+
2831
/// Options to adjust the behavior of this request, including plugin-options
2932
public let options: Options
3033

@@ -35,13 +38,15 @@ public struct GraphQLOperationRequest<R: Decodable>: AmplifyOperationRequest {
3538
variables: [String: Any]? = nil,
3639
responseType: R.Type,
3740
decodePath: String? = nil,
41+
authMode: AuthorizationMode? = nil,
3842
options: Options) {
3943
self.apiName = apiName
4044
self.operationType = operationType
4145
self.document = document
4246
self.variables = variables
4347
self.responseType = responseType
4448
self.decodePath = decodePath
49+
self.authMode = authMode
4550
self.options = options
4651
}
4752
}

Amplify/Categories/API/Request/GraphQLRequest.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
// SPDX-License-Identifier: Apache-2.0
66
//
77

8+
/// Empty protocol for plugins to define specific `AuthorizationMode` types for the request.
9+
public protocol AuthorizationMode { }
10+
811
/// GraphQL Request
912
public struct GraphQLRequest<R: Decodable> {
1013

@@ -21,6 +24,9 @@ public struct GraphQLRequest<R: Decodable> {
2124
/// Type to decode the graphql response data object to
2225
public let responseType: R.Type
2326

27+
/// The authorization mode
28+
public let authMode: AuthorizationMode?
29+
2430
/// The path to decode to the graphQL response data to `responseType`. Delimited by `.` The decode path
2531
/// "listTodos.items" will traverse to the object at `listTodos`, and decode the object at `items` to `responseType`
2632
/// The data at that decode path is a list of Todo objects so `responseType` should be `[Todo].self`
@@ -34,11 +40,13 @@ public struct GraphQLRequest<R: Decodable> {
3440
variables: [String: Any]? = nil,
3541
responseType: R.Type,
3642
decodePath: String? = nil,
43+
authMode: AuthorizationMode? = nil,
3744
options: GraphQLRequest<R>.Options? = nil) {
3845
self.apiName = apiName
3946
self.document = document
4047
self.variables = variables
4148
self.responseType = responseType
49+
self.authMode = authMode
4250
self.decodePath = decodePath
4351
self.options = options
4452
}

AmplifyPlugins/API/Sources/AWSAPIPlugin/Operation/AWSGraphQLOperation.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ final public class AWSGraphQLOperation<R: Decodable>: GraphQLOperation<R> {
4646
}
4747

4848
let urlRequest = validateRequest(request).flatMap(buildURLRequest(from:))
49-
let finalRequest = await getEndpointInterceptors(from: request).flatMapAsync { requestInterceptors in
49+
let finalRequest = await getEndpointInterceptors().flatMapAsync { requestInterceptors in
5050
let preludeInterceptors = requestInterceptors?.preludeInterceptors ?? []
5151
let customerInterceptors = requestInterceptors?.interceptors ?? []
5252
let postludeInterceptors = requestInterceptors?.postludeInterceptors ?? []
@@ -150,7 +150,7 @@ final public class AWSGraphQLOperation<R: Decodable>: GraphQLOperation<R> {
150150
}
151151
}
152152

153-
private func getEndpointInterceptors(from request: GraphQLOperationRequest<R>) -> Result<AWSAPIEndpointInterceptors?, APIError> {
153+
func getEndpointInterceptors() -> Result<AWSAPIEndpointInterceptors?, APIError> {
154154
getEndpointConfig(from: request).flatMap { endpointConfig in
155155
do {
156156
if let pluginOptions = request.options.pluginOptions as? AWSAPIPluginDataStoreOptions,
@@ -159,6 +159,11 @@ final public class AWSGraphQLOperation<R: Decodable>: GraphQLOperation<R> {
159159
withConfig: endpointConfig,
160160
authType: authType
161161
))
162+
} else if let authType = request.authMode as? AWSAuthorizationType {
163+
return .success(try pluginConfig.interceptorsForEndpoint(
164+
withConfig: endpointConfig,
165+
authType: authType
166+
))
162167
} else {
163168
return .success(pluginConfig.interceptorsForEndpoint(withConfig: endpointConfig))
164169
}

AmplifyPlugins/API/Sources/AWSAPIPlugin/Operation/AWSGraphQLSubscriptionTaskRunner.swift

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,21 @@ public class AWSGraphQLSubscriptionTaskRunner<R: Decodable>: InternalTaskRunner,
9191
return
9292
}
9393

94-
let pluginOptions = request.options.pluginOptions as? AWSAPIPluginDataStoreOptions
94+
let authType: AWSAuthorizationType?
95+
if let pluginOptions = request.options.pluginOptions as? AWSAPIPluginDataStoreOptions {
96+
authType = pluginOptions.authType
97+
} else if let authorizationMode = request.authMode as? AWSAuthorizationType {
98+
authType = authorizationMode
99+
} else {
100+
authType = nil
101+
}
95102
// Retrieve the subscription connection
96103
do {
97104
self.appSyncClient = try await appSyncClientFactory.getAppSyncRealTimeClient(
98105
for: endpointConfig,
99106
endpoint: endpointConfig.baseURL,
100107
authService: authService,
101-
authType: pluginOptions?.authType,
108+
authType: authType,
102109
apiAuthProviderFactory: apiAuthProviderFactory
103110
)
104111

@@ -262,14 +269,21 @@ final public class AWSGraphQLSubscriptionOperation<R: Decodable>: GraphQLSubscri
262269
return
263270
}
264271

265-
let pluginOptions = request.options.pluginOptions as? AWSAPIPluginDataStoreOptions
272+
let authType: AWSAuthorizationType?
273+
if let pluginOptions = request.options.pluginOptions as? AWSAPIPluginDataStoreOptions {
274+
authType = pluginOptions.authType
275+
} else if let authorizationMode = request.authMode as? AWSAuthorizationType {
276+
authType = authorizationMode
277+
} else {
278+
authType = nil
279+
}
266280
Task {
267281
do {
268282
appSyncRealTimeClient = try await appSyncRealTimeClientFactory.getAppSyncRealTimeClient(
269283
for: endpointConfig,
270284
endpoint: endpointConfig.baseURL,
271285
authService: authService,
272-
authType: pluginOptions?.authType,
286+
authType: authType,
273287
apiAuthProviderFactory: apiAuthProviderFactory
274288
)
275289

AmplifyPlugins/API/Sources/AWSAPIPlugin/Support/Utils/GraphQLRequest+toOperationRequest.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ extension GraphQLRequest {
1616
variables: variables,
1717
responseType: responseType,
1818
decodePath: decodePath,
19+
authMode: authMode,
1920
options: requestOptions)
2021
}
2122
}

AmplifyPlugins/API/Tests/AWSAPIPluginTests/AWSAPICategoryPlugin+GraphQLBehaviorTests.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
import XCTest
99
import Amplify
1010
@testable import AWSAPIPlugin
11+
import AWSPluginsCore
1112

1213
class AWSAPICategoryPluginGraphQLBehaviorTests: AWSAPICategoryPluginTestBase {
1314

1415
// MARK: Query API Tests
1516

1617
func testQuery() {
1718
let operationFinished = expectation(description: "Operation should finish")
18-
let request = GraphQLRequest(apiName: apiName,
19-
document: testDocument,
20-
variables: nil,
21-
responseType: JSONValue.self)
19+
let request = GraphQLRequest<JSONValue>(apiName: apiName,
20+
document: testDocument,
21+
variables: nil,
22+
responseType: JSONValue.self,
23+
authMode: AWSAuthorizationType.apiKey)
2224
let operation = apiPlugin.query(request: request) { _ in
2325
operationFinished.fulfill()
2426
}

0 commit comments

Comments
 (0)