diff --git a/Package.swift b/Package.swift index d64d2e3..2d54c64 100644 --- a/Package.swift +++ b/Package.swift @@ -12,7 +12,10 @@ let package = Package( ], targets: [ .target( - name: "GraphQLPagination" + name: "GraphQLPagination", + swiftSettings: [ + .enableExperimentalFeature("StrictConcurrency"), + ] ), .testTarget( name: "GraphQLPaginationTests", diff --git a/Sources/GraphQLPagination/Cursor.swift b/Sources/GraphQLPagination/Cursor.swift index 058d057..61f935d 100644 --- a/Sources/GraphQLPagination/Cursor.swift +++ b/Sources/GraphQLPagination/Cursor.swift @@ -1,6 +1,6 @@ import Foundation -public struct Cursor: RawRepresentable, Hashable { +public struct Cursor: RawRepresentable, Hashable, Sendable { public var rawValue: String public init(rawValue: String) { self.rawValue = rawValue diff --git a/Sources/GraphQLPagination/EdgeBuilder.swift b/Sources/GraphQLPagination/EdgeBuilder.swift index b3f2b95..1559976 100644 --- a/Sources/GraphQLPagination/EdgeBuilder.swift +++ b/Sources/GraphQLPagination/EdgeBuilder.swift @@ -1,7 +1,7 @@ import Foundation /// Describes how to create the cursor for a set of edges. -public enum CursorType { +public enum CursorType: Hashable, Sendable { /// The edge cursor is based on the node's `cursor` property. case identifier /// The edge cursor is based on the index of the node. @@ -37,6 +37,7 @@ public struct EdgesConstruction { } extension EdgesConstruction: Equatable where Edge: Equatable {} +extension EdgesConstruction: Sendable where Edge: Sendable {} /// A type that can transform a set of nodes into edges with pagination logic. public struct EdgeBuilder { @@ -96,6 +97,7 @@ struct Bounded { } extension Bounded: Equatable where T: Equatable {} +extension Bounded: Sendable where T: Sendable {} fileprivate extension Bounded { init(range: Range, count: Int, nodes: [T], cursors: [Cursor]) { diff --git a/Sources/GraphQLPagination/Offset.swift b/Sources/GraphQLPagination/Offset.swift index 20bb6a0..ebda7fd 100644 --- a/Sources/GraphQLPagination/Offset.swift +++ b/Sources/GraphQLPagination/Offset.swift @@ -2,7 +2,7 @@ import Foundation /// Traditional offset pagination, describing the offset of /// the first record, and the number of records to return. -public struct OffsetPagination: Equatable { +public struct OffsetPagination: Equatable, Sendable { public var offset: Int public var count: Int? public init(offset: Int = 0, count: Int? = nil) { diff --git a/Sources/GraphQLPagination/Pagination.swift b/Sources/GraphQLPagination/Pagination.swift index ac6def8..a2b0a46 100644 --- a/Sources/GraphQLPagination/Pagination.swift +++ b/Sources/GraphQLPagination/Pagination.swift @@ -1,7 +1,7 @@ import Foundation /// Pagination. -public enum GraphPagination { +public enum GraphPagination: Equatable, Sendable { case forward(GraphForwardPagination) case backward(GraphBackwardPagination) } @@ -50,7 +50,7 @@ extension GraphPaginatable { } /// A concrete forward pagination input. -public struct GraphForwardPagination: GraphForwardPaginatable { +public struct GraphForwardPagination: Equatable, Sendable, GraphForwardPaginatable { public var first: Int? public var after: Cursor? public init(first: Int? = nil, after: Cursor? = nil) { @@ -60,7 +60,7 @@ public struct GraphForwardPagination: GraphForwardPaginatable { } /// A concrete backward pagination input. -public struct GraphBackwardPagination: GraphBackwardPaginatable { +public struct GraphBackwardPagination: Equatable, Sendable, GraphBackwardPaginatable { public var last: Int? public var before: Cursor? public init(last: Int? = nil, before: Cursor? = nil) { @@ -70,7 +70,7 @@ public struct GraphBackwardPagination: GraphBackwardPaginatable { } /// Describes the state of pagination for output. -public struct GraphPageInfo: Equatable, Codable { +public struct GraphPageInfo: Equatable, Codable, Sendable { public let hasPreviousPage: Bool public let hasNextPage: Bool public let startCursor: Cursor?