Skip to content

Commit 6050e4b

Browse files
authored
chore(api): functional integ tests - paginate on list requests (#2665)
1 parent daa4a4b commit 6050e4b

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginFunctionalTests/GraphQLConnectionScenario3Tests+List.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,15 @@ extension GraphQLConnectionScenario3Tests {
130130

131131
let post = Post3.keys
132132
let predicate = post.id == uuid && post.title == uniqueTitle
133-
let graphQLResponse = try await Amplify.API.query(request: .list(Post3.self, where: predicate))
134-
guard case let .success(posts) = graphQLResponse else {
133+
let graphQLResponse = try await Amplify.API.query(request: .list(Post3.self, where: predicate, limit: 1000))
134+
guard case var .success(posts) = graphQLResponse else {
135135
XCTFail("Missing successful response")
136136
return
137137
}
138+
139+
while posts.count == 0 && posts.hasNextPage() {
140+
posts = try await posts.getNextPage()
141+
}
138142
XCTAssertEqual(posts.count, 1)
139143
guard let singlePost = posts.first else {
140144
XCTFail("Should only have a single post with the unique title")

AmplifyPlugins/API/Tests/APIHostApp/AWSAPIPluginFunctionalTests/GraphQLModelBasedTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,15 @@ class GraphQLModelBasedTests: XCTestCase {
178178
post.rating == 12.3 &&
179179
post.draft == true
180180

181-
let graphQLResponse = try await Amplify.API.query(request: .list(Post.self, where: predicate))
182-
guard case .success(let posts) = graphQLResponse else {
181+
let graphQLResponse = try await Amplify.API.query(request: .list(Post.self, where: predicate, limit: 1000))
182+
guard case .success(var posts) = graphQLResponse else {
183183
XCTFail("Missing successful response")
184184
return
185185
}
186+
187+
while posts.count == 0 && posts.hasNextPage() {
188+
posts = try await posts.getNextPage()
189+
}
186190
XCTAssertEqual(posts.count, 1)
187191
guard let singlePost = posts.first else {
188192
XCTFail("Should only have a single post with the unique title")

0 commit comments

Comments
 (0)