Skip to content

Commit

Permalink
allow isTruncated to be optional bool (#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
dayaffe authored Dec 4, 2023
1 parent 794b36b commit 2550e03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/ClientRuntime/Pagination/PaginatorSequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public struct PaginatorSequence<OperationStackInput: PaginateToken, OperationSta
let input: OperationStackInput
let inputKey: KeyPath<OperationStackInput, OperationStackInput.Token?>?
let outputKey: KeyPath<OperationStackOutput, OperationStackInput.Token?>
var isTruncatedKey: KeyPath<OperationStackOutput, Bool>?
var isTruncatedKey: KeyPath<OperationStackOutput, Bool?>?
let paginationFunction: (OperationStackInput) async throws -> OperationStackOutput

public init(input: OperationStackInput,
inputKey: KeyPath<OperationStackInput, OperationStackInput.Token?>? = nil,
outputKey: KeyPath<OperationStackOutput, OperationStackInput.Token?>,
isTruncatedKey: KeyPath<OperationStackOutput, Bool>? = nil,
isTruncatedKey: KeyPath<OperationStackOutput, Bool?>? = nil,
paginationFunction: @escaping (OperationStackInput) async throws -> OperationStackOutput) {
self.input = input
self.inputKey = inputKey
Expand Down Expand Up @@ -51,7 +51,7 @@ public struct PaginatorSequence<OperationStackInput: PaginateToken, OperationSta

// Use isTruncatedKey from the sequence to check if pagination should continue
if let isTruncatedKey = sequence.isTruncatedKey {
let isTruncated = output[keyPath: isTruncatedKey]
let isTruncated = output[keyPath: isTruncatedKey] ?? false
if !isTruncated {
// set token to nil to break out of the next iteration
token = nil
Expand Down

0 comments on commit 2550e03

Please sign in to comment.