Skip to content
Open
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
10 changes: 6 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "lldb",
"request": "launch",
"name": "Debug swift-graphql",
"program": ".build/debug/swift-graphql",
"program": "${workspaceFolder:swift-graphql}/.build/debug/swift-graphql",
"args": [],
"cwd": "${workspaceFolder:swift-graphql}",
"preLaunchTask": "swift: Build Debug swift-graphql"
Expand All @@ -13,7 +13,7 @@
"type": "lldb",
"request": "launch",
"name": "Release swift-graphql",
"program": ".build/release/swift-graphql",
"program": "${workspaceFolder:swift-graphql}/.build/release/swift-graphql",
"args": [],
"cwd": "${workspaceFolder:swift-graphql}",
"preLaunchTask": "swift: Build Release swift-graphql"
Expand All @@ -23,9 +23,11 @@
"request": "launch",
"name": "Test swift-graphql",
"program": "/Applications/Xcode.app/Contents/Developer/usr/bin/xctest",
"args": [".build/debug/swift-graphqlPackageTests.xctest"],
"args": [
".build/debug/swift-graphqlPackageTests.xctest"
],
"cwd": "${workspaceFolder:swift-graphql}",
"preLaunchTask": "swift: Build All"
}
]
}
}
15 changes: 7 additions & 8 deletions Formula/SwiftGraphQL.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ class Swiftgraphql < Formula
desc "Code generator for SwiftGraphQL library"
homepage "https://swift-graphql.org"
license "MIT"
version "5.1.2"

url "https://github.com/maticzav/swift-graphql/archive/5.1.2.tar.gz"
sha256 "a3b7af209356dc1362b807fd9a4f33dde47c2b815e034e6c7016f19968e8d33e"
url "file:///Users/bryananderson/Developer/Forks/swift-graphql", :using => :git, :branch => "swift-6-concurrency"

head "https://github.com/maticzav/swift-graphql.git"

depends_on :xcode
uses_from_macos "libxml2"
uses_from_macos "swift"

def install
system "make", "install", "PREFIX=#{prefix}"
system "swift", "build", "-c", "release", "--product", "swift-graphql"
bin.install ".build/release/swift-graphql"
end

def test
system "true"
test do
system "#{bin}/swift-graphql", "--version"
end
end
end
8 changes: 4 additions & 4 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// swift-tools-version:5.7
// swift-tools-version:6.0

import PackageDescription

let package = Package(
name: "swift-graphql",
platforms: [
.iOS(.v15),
.macOS(.v10_15),
.macOS(.v12),
.tvOS(.v13),
.watchOS(.v6)
],
Expand All @@ -25,7 +25,7 @@ let package = Package(
dependencies: [
// .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-format", "508.0.0"..<"510.0.0"),
.package(url: "https://github.com/apple/swift-format", from: "600.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/daltoniam/Starscream.git", from: "4.0.5"),
.package(url: "https://github.com/dominicegginton/Spinner", from: "2.0.0"),
Expand Down Expand Up @@ -69,7 +69,7 @@ let package = Package(
dependencies: [
"GraphQLAST",
.product(name: "SwiftFormat", package: "swift-format"),
.product(name: "SwiftFormatConfiguration", package: "swift-format"),
// .product(name: "SwiftFormatConfiguration", package: "swift-format"),
"SwiftGraphQLUtils"
],
path: "Sources/SwiftGraphQLCodegen"
Expand Down
41 changes: 23 additions & 18 deletions Sources/GraphQL/AnyCodable/AnyCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

/**
A type-erased `Codable` value.

The `AnyCodable` type forwards encoding and decoding responsibilities
to an underlying value, hiding its specific underlying type.

You can encode or decode mixed-type values in dictionaries
and other collections that require `Encodable` or `Decodable` conformance
by declaring their contained type to be `AnyCodable`.

- SeeAlso: `AnyEncodable`
- SeeAlso: `AnyDecodable`
*/
@frozen public struct AnyCodable: Codable {
@frozen public struct AnyCodable: Codable, @unchecked Sendable {
public let value: Any

public init<T>(_ value: T?) {
public init<T: Sendable>(_ value: T?) {
self.value = value ?? ()
}
}
Expand Down Expand Up @@ -91,40 +91,45 @@ extension AnyCodable: CustomDebugStringConvertible {
}

extension AnyCodable: ExpressibleByNilLiteral, ExpressibleByBooleanLiteral, ExpressibleByIntegerLiteral, ExpressibleByFloatLiteral, ExpressibleByStringLiteral, ExpressibleByArrayLiteral, ExpressibleByDictionaryLiteral {

public init(nilLiteral: ()) {
self.init(nil as Any?)
self.init(nil as Void?)
}

public init(booleanLiteral value: Bool) {
self.init(value)
}

public init(integerLiteral value: Int) {
self.init(value)
}

public init(floatLiteral value: Double) {
self.init(value)
}

public init(extendedGraphemeClusterLiteral value: String) {
self.init(value)
}

public init(stringLiteral value: String) {
self.init(value)
}

public init(arrayLiteral elements: Any...) {
public init(arrayLiteral elements: any Sendable...) {
self.init(elements)
}

public init(dictionaryLiteral elements: (AnyHashable, Any)...) {
self.init(Dictionary<AnyHashable, Any>(elements, uniquingKeysWith: { (first, _) in first }))
public init<T: HashSendable>(dictionaryLiteral elements: (T, any Sendable)...) {
self.init(Dictionary<T, any Sendable>(elements, uniquingKeysWith: { (first, _) in first }))
}


}

public typealias HashSendable = Hashable & Sendable



extension AnyCodable: Hashable {
public func hash(into hasher: inout Hasher) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQL/AnyCodable/AnyDecodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import Foundation
let decoder = JSONDecoder()
let dictionary = try! decoder.decode([String: AnyDecodable].self, from: json)
*/
@frozen public struct AnyDecodable: Decodable {
@frozen public struct AnyDecodable: Decodable, @unchecked Sendable {
public let value: Any

public init<T>(_ value: T?) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQL/AnyCodable/AnyEncodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import Foundation
let encoder = JSONEncoder()
let json = try! encoder.encode(dictionary)
*/
@frozen public struct AnyEncodable: Encodable {
@frozen public struct AnyEncodable: Encodable, @unchecked Sendable {
public let value: Any

public init<T>(_ value: T?) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQL/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
/// A GraphQLError describes an Error found during the parse, validate, or execute phases of performing a GraphQL operation. In addition to a message and stack trace, it also includes information about the locations in a GraphQL document and/or execution result that correspond to the Error.
///
/// Its implementation follows the specification described at [GraphQLSpec](http://spec.graphql.org/October2021/#sec-Errors.Error-result-format).
public struct GraphQLError: Codable, Equatable {
public struct GraphQLError: Codable, Equatable, Sendable {

/// A short, human-readable summary of the problem.
public let message: String
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQL/Execution.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
/// The structure holding parameters for a GraphQL request.
///
/// ExecutionArgs contains fields in the [GraphQL over HTTP spec](https://github.com/graphql/graphql-over-http/blob/main/spec/GraphQLOverHTTP.md#request-parameters) and [GraphQL over WebSocket](https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md#subscribe) spec.
public struct ExecutionArgs: Codable, Equatable {
public struct ExecutionArgs: Codable, Equatable, Sendable {

/// A Document containing GraphQL Operations and Fragments to execute.
public var query: String
Expand Down
2 changes: 1 addition & 1 deletion Sources/GraphQLWebSocket/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Starscream
///
/// - NOTE: The client assumes that you'll manually establish the socket connection
/// and that it may send requests.
public class GraphQLWebSocket: WebSocketDelegate {
public final class GraphQLWebSocket: @preconcurrency WebSocketDelegate {

/// Configuration of the behaviour of the client.
private let config: GraphQLWebSocketConfiguration
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftGraphQL/Document/Argument.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import GraphQL
We use it internally in the generated code to pass down information
about the field and the type of the field it encodes as well as the value itself.
*/
public struct Argument: Hashable {
public struct Argument: Hashable, Sendable {
let name: String
let type: String
let hash: String
Expand Down Expand Up @@ -40,7 +40,7 @@ public struct Argument: Hashable {
// MARK: - Initializer

/// Returns a new argument with the given value.
public init<S: Hashable>(name: String, type: String, value: S) {
public init<S: Sendable & Hashable>(name: String, type: String, value: S) {
// Argument information
self.name = name
self.type = type
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftGraphQL/Document/Field.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import SwiftGraphQLUtils
/// what the selection should be and what the selected types are.
///
/// - NOTE: `interface` field in the `fragment` field may be a union or an interface.
public enum GraphQLField {
public enum GraphQLField: Sendable {
public typealias SelectionSet = [GraphQLField]

/// Composite field describes a selection on an object an union or an interface.
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftGraphQL/Document/Scalar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import GraphQL

/// Protocol that a custom scalar should implement to be used with SwiftGraphQL.
public protocol GraphQLScalar: Encodable {
public protocol GraphQLScalar: Encodable, Sendable {

/// A decoder from the any-type codable value.
init(from: AnyCodable) throws
Expand All @@ -20,7 +20,7 @@ extension Array: GraphQLScalar where Element: GraphQLScalar {
switch(codable.value) {
case let value as [AnyCodable]:
self = try value.map { try Element(from: $0) }
case let value as [Any]:
case let value as [any Sendable]:
// NOTE: We need this special case because wrapped scalar types (e.g. `[String]` or `String?`) are represented as a single `AnyCodable` value with a nested structure (e.g. `AnyCodable([String])`).
self = try value.map { try Element(from: AnyCodable($0)) }
default:
Expand Down Expand Up @@ -185,7 +185,7 @@ extension AnyCodable: GraphQLScalar {

// MARK: - Error

public enum ScalarDecodingError: Error {
public enum ScalarDecodingError: Error, @unchecked Sendable {

/// Scalar expected a given type but received a value of a different type.
case unexpectedScalarType(expected: String, received: Any)
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftGraphQL/Selection/Operation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public protocol GraphQLOperation {
static var operation: GraphQLOperationKind { get }
}

public enum GraphQLOperationKind: String {
public enum GraphQLOperationKind: String, Sendable {
case query
case mutation
case subscription
Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftGraphQL/Selection/Selection+Transform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public extension Selection {
switch fields.__state {
case let .decoding(data):
switch data.value {
case let array as [Any]:
case let array as [any Sendable]:
return try array.map { try self.__decode(data: AnyCodable($0)) }
default:
throw ObjectDecodingError.unexpectedObjectType(expected: "Array", received: data.value)
Expand Down Expand Up @@ -85,7 +85,7 @@ public extension Selection {
public extension Selection {

/// Maps selection's return value into a new value using provided mapping function.
func map<MappedType>(_ fn: @escaping (T) -> MappedType) -> Selection<MappedType, TypeLock> {
func map<MappedType>(_ fn: @Sendable @escaping (T) -> MappedType) -> Selection<MappedType, TypeLock> {
Selection<MappedType, TypeLock> { fields in
let selection = self.__selection()
fields.__select(selection)
Expand Down
Loading