Skip to content

Commit 767c59b

Browse files
authored
Merge pull request #2706 from aws-amplify/v1
chore: kickoff v1 release
2 parents 9de8030 + 8e6f0a2 commit 767c59b

File tree

82 files changed

+2794
-659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+2794
-659
lines changed

AWSPluginsCore.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$AMPLIFY_VERSION = '1.28.4'
1111
$AMPLIFY_RELEASE_TAG = "v#{$AMPLIFY_VERSION}"
1212

13-
$AWS_SDK_VERSION = '2.29.1'
13+
$AWS_SDK_VERSION = '2.30.1'
1414
$OPTIMISTIC_AWS_SDK_VERSION = "~> #{$AWS_SDK_VERSION}"
1515

1616
Pod::Spec.new do |s|

AWSPredictionsPlugin.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
$AMPLIFY_VERSION = '1.28.4'
33
$AMPLIFY_RELEASE_TAG = "v#{$AMPLIFY_VERSION}"
44

5-
$AWS_SDK_VERSION = '2.29.1'
5+
$AWS_SDK_VERSION = '2.30.1'
66
$OPTIMISTIC_AWS_SDK_VERSION = "~> #{$AWS_SDK_VERSION}"
77

88
Pod::Spec.new do |s|

Amplify/Categories/API/Request/RESTRequest.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,14 @@ public class RESTRequest {
3232
headers: [String: String]? = nil,
3333
queryParameters: [String: String]? = nil,
3434
body: Data? = nil) {
35+
let inputHeaders = headers ?? [:]
36+
self.headers = inputHeaders.merging(
37+
["Cache-Control": "no-store"],
38+
uniquingKeysWith: { current, _ in current}
39+
)
40+
3541
self.apiName = apiName
3642
self.path = path
37-
self.headers = headers
3843
self.queryParameters = queryParameters
3944
self.body = body
4045
}

Amplify/Categories/DataStore/DataStoreCategory+Behavior+Combine.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public extension DataStoreBaseBehavior {
5353
_ modelType: M.Type,
5454
withIdentifier identifier: String,
5555
where predicate: QueryPredicate? = nil
56-
) -> DataStorePublisher<Void> where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default {
56+
) -> DataStorePublisher<Void> where M: ModelIdentifiable, M.IdentifierFormat == ModelIdentifierFormat.Default {
5757
Future { promise in
5858
self.delete(modelType, withIdentifier: identifier, where: predicate) { promise($0) }
5959
}.eraseToAnyPublisher()
@@ -70,7 +70,7 @@ public extension DataStoreBaseBehavior {
7070
_ modelType: M.Type,
7171
withIdentifier identifier: ModelIdentifier<M, M.IdentifierFormat>,
7272
where predicate: QueryPredicate? = nil
73-
) -> DataStorePublisher<Void> where M: ModelIdentifiable {
73+
) -> DataStorePublisher<Void> where M: ModelIdentifiable {
7474
Future { promise in
7575
self.delete(modelType, withIdentifier: identifier, where: predicate) { promise($0) }
7676
}.eraseToAnyPublisher()

AmplifyPlugins.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
$AMPLIFY_VERSION = '1.28.4'
1111
$AMPLIFY_RELEASE_TAG = "v#{$AMPLIFY_VERSION}"
1212

13-
$AWS_SDK_VERSION = '2.29.1'
13+
$AWS_SDK_VERSION = '2.30.1'
1414
$OPTIMISTIC_AWS_SDK_VERSION = "~> #{$AWS_SDK_VERSION}"
1515

1616
Pod::Spec.new do |s|
@@ -36,7 +36,7 @@ Pod::Spec.new do |s|
3636

3737
s.subspec 'AWSAPIPlugin' do |ss|
3838
ss.source_files = 'AmplifyPlugins/API/AWSAPICategoryPlugin/**/*.swift'
39-
ss.dependency 'AppSyncRealTimeClient', "~> 2.0"
39+
ss.dependency 'AppSyncRealTimeClient', "~> 3.0"
4040
end
4141

4242
s.subspec 'AWSCognitoAuthPlugin' do |ss|

AmplifyPlugins/API/AWSAPICategoryPlugin/Operation/AWSGraphQLSubscriptionOperation.swift

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,17 @@ final public class AWSGraphQLSubscriptionOperation<R: Decodable>: GraphQLSubscri
9393
// Retrieve request plugin option and
9494
// auth type in case of a multi-auth setup
9595
let pluginOptions = request.options.pluginOptions as? AWSPluginOptions
96+
let urlRequest = generateSubscriptionURLRequest(from: endpointConfig)
9697

9798
// Retrieve the subscription connection
9899
subscriptionQueue.sync {
99100
do {
100101
subscriptionConnection = try subscriptionConnectionFactory
101102
.getOrCreateConnection(for: endpointConfig,
102-
authService: authService,
103-
authType: pluginOptions?.authType,
104-
apiAuthProviderFactory: apiAuthProviderFactory)
103+
urlRequest: urlRequest,
104+
authService: authService,
105+
authType: pluginOptions?.authType,
106+
apiAuthProviderFactory: apiAuthProviderFactory)
105107
} catch {
106108
let error = APIError.operationError("Unable to get connection for api \(endpointConfig.name)", "", error)
107109
dispatch(result: .failure(error))
@@ -119,6 +121,17 @@ final public class AWSGraphQLSubscriptionOperation<R: Decodable>: GraphQLSubscri
119121
}
120122
}
121123

124+
private func generateSubscriptionURLRequest(
125+
from endpointConfig: AWSAPICategoryPluginConfiguration.EndpointConfig
126+
) -> URLRequest {
127+
var urlRequest = URLRequest(url: endpointConfig.baseURL)
128+
urlRequest.setValue(
129+
AmplifyAWSServiceConfiguration.baseUserAgent(),
130+
forHTTPHeaderField: URLRequestConstants.Header.userAgent
131+
)
132+
return urlRequest
133+
}
134+
122135
private func onAsyncSubscriptionEvent(event: SubscriptionItemEvent) {
123136
switch event {
124137
case .connection(let subscriptionConnectionEvent):

AmplifyPlugins/API/AWSAPICategoryPlugin/SubscriptionFactory/AWSSubscriptionConnectionFactory.swift

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,24 @@ class AWSSubscriptionConnectionFactory: SubscriptionConnectionFactory {
2323

2424
private var apiToConnectionProvider: [MapperCacheKey: ConnectionProvider] = [:]
2525

26-
func getOrCreateConnection(for endpointConfig: AWSAPICategoryPluginConfiguration.EndpointConfig,
27-
authService: AWSAuthServiceBehavior,
28-
authType: AWSAuthorizationType? = nil,
29-
apiAuthProviderFactory: APIAuthProviderFactory) throws -> SubscriptionConnection {
26+
func getOrCreateConnection(
27+
for endpointConfig: AWSAPICategoryPluginConfiguration.EndpointConfig,
28+
urlRequest: URLRequest,
29+
authService: AWSAuthServiceBehavior,
30+
authType: AWSAuthorizationType? = nil,
31+
apiAuthProviderFactory: APIAuthProviderFactory
32+
) throws -> SubscriptionConnection {
3033
return try concurrencyQueue.sync {
3134
let apiName = endpointConfig.name
3235

33-
let url = endpointConfig.baseURL
34-
3536
let authInterceptor = try getInterceptor(for: getOrCreateAuthConfiguration(from: endpointConfig,
3637
authType: authType),
3738
authService: authService,
3839
apiAuthProviderFactory: apiAuthProviderFactory)
3940

4041
// create or retrieve the connection provider. If creating, add interceptors onto the provider.
4142
let connectionProvider = apiToConnectionProvider[MapperCacheKey(apiName: apiName, authType: authType)] ??
42-
ConnectionProviderFactory.createConnectionProvider(for: url,
43+
ConnectionProviderFactory.createConnectionProvider(for: urlRequest,
4344
authInterceptor: authInterceptor,
4445
connectionType: .appSyncRealtime)
4546

AmplifyPlugins/API/AWSAPICategoryPlugin/SubscriptionFactory/SubscriptionConnectionFactory.swift

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

8+
import Foundation
9+
810
import Amplify
911
import AWSPluginsCore
1012
import AppSyncRealTimeClient
@@ -14,6 +16,7 @@ protocol SubscriptionConnectionFactory {
1416

1517
/// Get connection based on the connection type
1618
func getOrCreateConnection(for endpointConfig: AWSAPICategoryPluginConfiguration.EndpointConfig,
19+
urlRequest: URLRequest,
1720
authService: AWSAuthServiceBehavior,
1821
authType: AWSAuthorizationType?,
1922
apiAuthProviderFactory: APIAuthProviderFactory) throws -> SubscriptionConnection

AmplifyPlugins/API/AWSAPICategoryPlugin/Support/Utils/GraphQLOperationRequestUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GraphQLOperationRequestUtils {
2222
// Construct a graphQL specific HTTP POST request with the request payload
2323
static func constructRequest(with baseUrl: URL, requestPayload: Data) -> URLRequest {
2424
var baseRequest = URLRequest(url: baseUrl)
25-
let headers = ["content-type": "application/json"]
25+
let headers = ["content-type": "application/json", "Cache-Control": "no-store"]
2626
baseRequest.allHTTPHeaderFields = headers
2727
baseRequest.httpMethod = "POST"
2828
baseRequest.httpBody = requestPayload

AmplifyPlugins/API/AWSAPICategoryPluginFunctionalTests/GraphQLModelBased/GraphQLConnectionScenario3Tests+List.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,27 @@ extension GraphQLConnectionScenario3Tests {
194194
let requestInvokedSuccessfully = expectation(description: "request completed")
195195
let post = Post3.keys
196196
let predicate = post.id == uuid && post.title == uniqueTitle
197-
_ = Amplify.API.query(request: .list(Post3.self, where: predicate)) { event in
197+
_ = Amplify.API.query(request: .paginatedList(Post3.self, where: predicate)) { event in
198198
switch event {
199199
case .success(let graphQLResponse):
200-
guard case let .success(posts) = graphQLResponse else {
200+
guard case var .success(posts) = graphQLResponse else {
201201
XCTFail("Missing successful response")
202202
return
203203
}
204+
205+
while posts.isEmpty, posts.hasNextPage() {
206+
let getNextPageCompleted = self.expectation(description: "get next page completed")
207+
posts.getNextPage { result in
208+
switch result {
209+
case .success(let nextPage):
210+
posts = nextPage
211+
getNextPageCompleted.fulfill()
212+
case .failure(let error):
213+
XCTFail("Failed with error \(error)")
214+
}
215+
}
216+
self.wait(for: [getNextPageCompleted], timeout: TestCommonConstants.networkTimeout)
217+
}
204218
XCTAssertEqual(posts.count, 1)
205219
guard let singlePost = posts.first else {
206220
XCTFail("Should only have a single post with the unique title")

0 commit comments

Comments
 (0)