Skip to content

Commit 20c8d02

Browse files
Merge pull request #159 from NeedleInAJayStack/refactor/swift-format
Converts to swift-format
2 parents f4fb7b2 + ab3374e commit 20c8d02

53 files changed

Lines changed: 1200 additions & 1304 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.swift-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"version": 1,
3+
"indentation" : {
4+
"spaces" : 4
5+
},
6+
"lineBreakBeforeEachArgument": true
7+
}

Package.swift

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ let package = Package(
55
name: "Graphiti",
66
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)],
77
products: [
8-
.library(name: "Graphiti", targets: ["Graphiti"]),
8+
.library(name: "Graphiti", targets: ["Graphiti"])
99
],
1010
dependencies: [
11-
.package(url: "https://github.com/GraphQLSwift/GraphQL.git", from: "4.0.0"),
11+
.package(url: "https://github.com/GraphQLSwift/GraphQL.git", from: "4.0.0")
1212
],
1313
targets: [
1414
.target(name: "Graphiti", dependencies: ["GraphQL"]),
15-
.testTarget(name: "GraphitiTests", dependencies: ["Graphiti"], resources: [
16-
.copy("FederationTests/GraphQL"),
17-
]),
15+
.testTarget(
16+
name: "GraphitiTests",
17+
dependencies: ["Graphiti"],
18+
resources: [
19+
.copy("FederationTests/GraphQL")
20+
]
21+
),
1822
],
1923
swiftLanguageVersions: [.v5, .version("6")]
2024
)

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,11 +237,11 @@ This package supports Swift versions in [alignment with Swift NIO](https://githu
237237

238238
## Contributing
239239

240-
This repo uses [SwiftFormat](https://github.com/nicklockwood/SwiftFormat), and includes lint checks to enforce these formatting standards.
241-
To format your code, install `swiftformat` and run:
240+
This repo uses the standard [swift format](https://github.com/swiftlang/swift-format), and includes lint checks to enforce these formatting standards.
241+
To format your code, run:
242242

243243
```bash
244-
swiftformat .
244+
swift format --parallel --in-place --recursive ./
245245
```
246246

247247
## License

Sources/Graphiti/API/API.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ public protocol API {
77
var schema: Schema<Resolver, ContextType> { get }
88
}
99

10-
public extension API {
11-
func execute(
10+
extension API {
11+
public func execute(
1212
request: String,
1313
context: ContextType,
1414
variables: [String: Map] = [:],
@@ -25,7 +25,7 @@ public extension API {
2525
)
2626
}
2727

28-
func execute(
28+
public func execute(
2929
request: GraphQLRequest,
3030
context: ContextType,
3131
validationRules: [@Sendable (ValidationContext) -> Visitor] = []
@@ -39,7 +39,7 @@ public extension API {
3939
)
4040
}
4141

42-
func subscribe(
42+
public func subscribe(
4343
request: String,
4444
context: ContextType,
4545
variables: [String: Map] = [:],
@@ -56,7 +56,7 @@ public extension API {
5656
)
5757
}
5858

59-
func subscribe(
59+
public func subscribe(
6060
request: GraphQLRequest,
6161
context: ContextType,
6262
validationRules: [@Sendable (ValidationContext) -> Visitor] = []

Sources/Graphiti/Argument/Argument.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,17 @@ public class Argument<ArgumentsType: Decodable, ArgumentType>: ArgumentComponent
2626
}
2727
}
2828

29-
public extension Argument {
30-
convenience init(
29+
extension Argument {
30+
public convenience init(
3131
_ name: String,
3232
at _: KeyPath<ArgumentsType, ArgumentType>
3333
) {
3434
self.init(name: name)
3535
}
3636
}
3737

38-
public extension Argument where ArgumentType: Encodable {
39-
func defaultValue(_ defaultValue: ArgumentType) -> Self {
38+
extension Argument where ArgumentType: Encodable {
39+
public func defaultValue(_ defaultValue: ArgumentType) -> Self {
4040
self.defaultValue = AnyEncodable(defaultValue)
4141
return self
4242
}

Sources/Graphiti/Argument/ArgumentComponent.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ public class ArgumentComponent<ArgumentsType: Decodable> {
1515
}
1616
}
1717

18-
public extension ArgumentComponent {
19-
func description(_ description: String) -> Self {
18+
extension ArgumentComponent {
19+
public func description(_ description: String) -> Self {
2020
self.description = description
2121
return self
2222
}

Sources/Graphiti/Component/Component.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ open class Component<Resolver: Sendable, Context: Sendable> {
1313
func update(typeProvider _: SchemaTypeProvider, coders _: Coders) throws {}
1414
}
1515

16-
public extension Component {
17-
func description(_ description: String) -> Self {
16+
extension Component {
17+
public func description(_ description: String) -> Self {
1818
self.description = description
1919
return self
2020
}

Sources/Graphiti/Connection/Connection.swift

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,36 @@ public struct Connection<Node: Sendable>: Sendable {
66
public let pageInfo: PageInfo
77
}
88

9-
public extension Connection where Node: Identifiable, Node.ID: LosslessStringConvertible {
10-
static func id(_ cursor: String) -> Node.ID? {
9+
extension Connection where Node: Identifiable, Node.ID: LosslessStringConvertible {
10+
public static func id(_ cursor: String) -> Node.ID? {
1111
cursor.base64Decoded().flatMap { Node.ID($0) }
1212
}
1313

14-
static func cursor(_ node: Node) -> String {
14+
public static func cursor(_ node: Node) -> String {
1515
node.id.description.base64Encoded()!
1616
}
1717
}
1818

19-
public extension Sequence where Element: Sendable, Element: Identifiable,
20-
Element.ID: LosslessStringConvertible {
21-
func connection(from arguments: Paginatable) throws -> Connection<Element> {
19+
extension Sequence
20+
where
21+
Element: Sendable, Element: Identifiable,
22+
Element.ID: LosslessStringConvertible
23+
{
24+
public func connection(from arguments: Paginatable) throws -> Connection<Element> {
2225
try connection(from: arguments, makeCursor: Connection<Element>.cursor)
2326
}
2427

25-
func connection(from arguments: ForwardPaginatable) throws -> Connection<Element> {
28+
public func connection(from arguments: ForwardPaginatable) throws -> Connection<Element> {
2629
try connection(from: arguments, makeCursor: Connection<Element>.cursor)
2730
}
2831

29-
func connection(from arguments: BackwardPaginatable) throws -> Connection<Element> {
32+
public func connection(from arguments: BackwardPaginatable) throws -> Connection<Element> {
3033
try connection(from: arguments, makeCursor: Connection<Element>.cursor)
3134
}
3235
}
3336

34-
public extension Sequence where Element: Sendable {
35-
func connection(
37+
extension Sequence where Element: Sendable {
38+
public func connection(
3639
from arguments: Paginatable,
3740
makeCursor: @escaping (Element) throws -> String
3841
) throws -> Connection<Element> {
@@ -43,7 +46,7 @@ public extension Sequence where Element: Sendable {
4346
)
4447
}
4548

46-
func connection(
49+
public func connection(
4750
from arguments: ForwardPaginatable,
4851
makeCursor: @escaping (Element) throws -> String
4952
) throws -> Connection<Element> {
@@ -54,7 +57,7 @@ public extension Sequence where Element: Sendable {
5457
)
5558
}
5659

57-
func connection(
60+
public func connection(
5861
from arguments: BackwardPaginatable,
5962
makeCursor: @escaping (Element) throws -> String
6063
) throws -> Connection<Element> {
@@ -96,19 +99,16 @@ func slicingCursor<Node>(
9699
) -> ArraySlice<Edge<Node>> {
97100
var edges = ArraySlice(edges)
98101

99-
if
100-
let after = arguments.after,
101-
let afterIndex = edges
102-
.firstIndex(where: { $0.cursor == after })?
103-
.advanced(by: 1)
102+
if let after = arguments.after,
103+
let afterIndex =
104+
edges.firstIndex(where: { $0.cursor == after })?.advanced(by: 1)
104105
{
105106
edges = edges[afterIndex...]
106107
}
107108

108-
if
109-
let before = arguments.before,
110-
let beforeIndex = edges
111-
.firstIndex(where: { $0.cursor == before })
109+
if let before = arguments.before,
110+
let beforeIndex =
111+
edges.firstIndex(where: { $0.cursor == before })
112112
{
113113
edges = edges[..<beforeIndex]
114114
}

Sources/Graphiti/Connection/ConnectionType.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ public final class ConnectionType<
44
Resolver: Sendable,
55
Context: Sendable,
66
ObjectType: Sendable
7-
>: TypeComponent<
8-
Resolver,
9-
Context
10-
> {
7+
>: TypeComponent<Resolver, Context> {
118
override func update(typeProvider: SchemaTypeProvider, coders: Coders) throws {
129
if !typeProvider.contains(type: PageInfo.self) {
1310
let pageInfo = Type<Resolver, Context, PageInfo>(PageInfo.self) {
@@ -52,8 +49,8 @@ public final class ConnectionType<
5249
}
5350
}
5451

55-
public extension ConnectionType {
56-
convenience init(
52+
extension ConnectionType {
53+
public convenience init(
5754
_ type: ObjectType.Type,
5855
as name: String? = nil
5956
) {

0 commit comments

Comments
 (0)