Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable strict concurrency and fix warnings #1

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ let package = Package(
],
targets: [
.target(
name: "GraphQLPagination"
name: "GraphQLPagination",
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),
]
),
.testTarget(
name: "GraphQLPaginationTests",
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQLPagination/Cursor.swift
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 3 additions & 1 deletion Sources/GraphQLPagination/EdgeBuilder.swift
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -37,6 +37,7 @@ public struct EdgesConstruction<Edge> {
}

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<Node: GraphCursorable, Edge> {
Expand Down Expand Up @@ -96,6 +97,7 @@ struct Bounded<T> {
}

extension Bounded: Equatable where T: Equatable {}
extension Bounded: Sendable where T: Sendable {}

fileprivate extension Bounded {
init(range: Range<Int>, count: Int, nodes: [T], cursors: [Cursor]) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQLPagination/Offset.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 4 additions & 4 deletions Sources/GraphQLPagination/Pagination.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

/// Pagination.
public enum GraphPagination {
public enum GraphPagination: Equatable, Sendable {
case forward(GraphForwardPagination)
case backward(GraphBackwardPagination)
}
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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?
Expand Down
Loading