Skip to content

Commit 3930b12

Browse files
committed
run swift format
1 parent c4baf42 commit 3930b12

File tree

5 files changed

+73
-71
lines changed

5 files changed

+73
-71
lines changed

Sources/Graphiti/Federation/Key/Type+Key.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import GraphQL
22

33
public extension Type {
4-
@discardableResult
54
/// Define and add the federated key to this type.
65
///
76
/// For more information, see https://www.apollographql.com/docs/federation/entities
87
/// - Parameters:
98
/// - function: The resolver function used to load this entity based on the key value.
109
/// - _: The key value. The name of this argument must match a Type field.
1110
/// - Returns: Self for chaining.
11+
@discardableResult
1212
func key<Arguments: Codable>(
1313
at function: @escaping AsyncResolve<Resolver, Context, Arguments, ObjectType?>,
1414
@ArgumentComponentBuilder<Arguments> _ argument: () -> ArgumentComponent<Arguments>
@@ -17,14 +17,14 @@ public extension Type {
1717
return self
1818
}
1919

20-
@discardableResult
2120
/// Define and add the federated key to this type.
2221
///
2322
/// For more information, see https://www.apollographql.com/docs/federation/entities
2423
/// - Parameters:
2524
/// - function: The resolver function used to load this entity based on the key value.
2625
/// - _: The key values. The names of these arguments must match Type fields.
2726
/// - Returns: Self for chaining.
27+
@discardableResult
2828
func key<Arguments: Codable>(
2929
at function: @escaping AsyncResolve<Resolver, Context, Arguments, ObjectType?>,
3030
@ArgumentComponentBuilder<Arguments> _ arguments: ()
@@ -34,14 +34,14 @@ public extension Type {
3434
return self
3535
}
3636

37-
@discardableResult
3837
/// Define and add the federated key to this type.
3938
///
4039
/// For more information, see https://www.apollographql.com/docs/federation/entities
4140
/// - Parameters:
4241
/// - function: The resolver function used to load this entity based on the key value.
4342
/// - _: The key value. The name of this argument must match a Type field.
4443
/// - Returns: Self for chaining.
44+
@discardableResult
4545
func key<Arguments: Codable>(
4646
at function: @escaping SimpleAsyncResolve<Resolver, Context, Arguments, ObjectType?>,
4747
@ArgumentComponentBuilder<Arguments> _ argument: () -> ArgumentComponent<Arguments>
@@ -50,14 +50,14 @@ public extension Type {
5050
return self
5151
}
5252

53-
@discardableResult
5453
/// Define and add the federated key to this type.
5554
///
5655
/// For more information, see https://www.apollographql.com/docs/federation/entities
5756
/// - Parameters:
5857
/// - function: The resolver function used to load this entity based on the key value.
5958
/// - _: The key values. The names of these arguments must match Type fields.
6059
/// - Returns: Self for chaining.
60+
@discardableResult
6161
func key<Arguments: Codable>(
6262
at function: @escaping SimpleAsyncResolve<Resolver, Context, Arguments, ObjectType?>,
6363
@ArgumentComponentBuilder<Arguments> _ arguments: ()
@@ -67,14 +67,14 @@ public extension Type {
6767
return self
6868
}
6969

70-
@discardableResult
7170
/// Define and add the federated key to this type.
7271
///
7372
/// For more information, see https://www.apollographql.com/docs/federation/entities
7473
/// - Parameters:
7574
/// - function: The resolver function used to load this entity based on the key value.
7675
/// - _: The key value. The name of this argument must match a Type field.
7776
/// - Returns: Self for chaining.
77+
@discardableResult
7878
func key<Arguments: Codable>(
7979
at function: @escaping SyncResolve<Resolver, Context, Arguments, ObjectType?>,
8080
@ArgumentComponentBuilder<Arguments> _ arguments: ()
@@ -84,14 +84,14 @@ public extension Type {
8484
return self
8585
}
8686

87-
@discardableResult
8887
/// Define and add the federated key to this type.
8988
///
9089
/// For more information, see https://www.apollographql.com/docs/federation/entities
9190
/// - Parameters:
9291
/// - function: The resolver function used to load this entity based on the key value.
9392
/// - _: The key values. The names of these arguments must match Type fields.
9493
/// - Returns: Self for chaining.
94+
@discardableResult
9595
func key<Arguments: Codable>(
9696
at function: @escaping SyncResolve<Resolver, Context, Arguments, ObjectType?>,
9797
@ArgumentComponentBuilder<Arguments> _ argument: () -> ArgumentComponent<Arguments>
@@ -102,15 +102,15 @@ public extension Type {
102102
}
103103

104104
public extension Type {
105-
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
106-
@discardableResult
107105
/// Define and add the federated key to this type.
108106
///
109107
/// For more information, see https://www.apollographql.com/docs/federation/entities
110108
/// - Parameters:
111109
/// - function: The resolver function used to load this entity based on the key value.
112110
/// - _: The key value. The name of this argument must match a Type field.
113111
/// - Returns: Self for chaining.
112+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
113+
@discardableResult
114114
func key<Arguments: Codable>(
115115
at function: @escaping ConcurrentResolve<Resolver, Context, Arguments, ObjectType?>,
116116
@ArgumentComponentBuilder<Arguments> _ argument: () -> ArgumentComponent<Arguments>
@@ -119,15 +119,15 @@ public extension Type {
119119
return self
120120
}
121121

122-
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
123-
@discardableResult
124122
/// Define and add the federated key to this type.
125123
///
126124
/// For more information, see https://www.apollographql.com/docs/federation/entities
127125
/// - Parameters:
128126
/// - function: The resolver function used to load this entity based on the key value.
129127
/// - _: The key values. The names of these arguments must match Type fields.
130128
/// - Returns: Self for chaining.
129+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
130+
@discardableResult
131131
func key<Arguments: Codable>(
132132
at function: @escaping ConcurrentResolve<Resolver, Context, Arguments, ObjectType?>,
133133
@ArgumentComponentBuilder<Arguments> _ arguments: () -> [ArgumentComponent<Arguments>]

Sources/Graphiti/Schema/Schema.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ public final class Schema<Resolver, Context> {
2121
}
2222

2323
guard typeProvider.query != nil || !typeProvider.federatedResolvers.isEmpty else {
24-
throw SchemaError(description: "Schema must contain at least 1 query or federated resolver")
24+
throw SchemaError(
25+
description: "Schema must contain at least 1 query or federated resolver"
26+
)
2527
}
2628

2729
schema = try GraphQLSchema(

Sources/Graphiti/SchemaBuilders/SchemaBuilder.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public final class SchemaBuilder<Resolver, Context> {
2727
subscriptionFields = []
2828
}
2929

30-
@discardableResult
3130
/// Allows for setting API encoders and decoders with customized settings.
3231
/// - Parameter newCoders: The new coders to use
3332
/// - Returns: This object for method chaining
33+
@discardableResult
3434
public func setCoders(to newCoders: Coders) -> Self {
3535
coders = newCoders
3636
return self
3737
}
3838

39-
@discardableResult
4039
/// Allows for setting SDL for federated subgraphs.
4140
/// - Parameter newSDL: The new SDL to use
4241
/// - Returns: This object for method chaining
42+
@discardableResult
4343
public func setFederatedSDL(to newSDL: String) -> Self {
4444
federatedSDL = newSDL
4545
return self
@@ -63,10 +63,10 @@ public final class SchemaBuilder<Resolver, Context> {
6363
return self
6464
}
6565

66-
@discardableResult
6766
/// Adds multiple query operation definitions to the schema.
6867
/// - Parameter component: The query operations to add
6968
/// - Returns: This object for method chaining
69+
@discardableResult
7070
public func add(
7171
@TypeComponentBuilder<Resolver, Context> _ components: ()
7272
-> [TypeComponent<Resolver, Context>]
@@ -77,10 +77,10 @@ public final class SchemaBuilder<Resolver, Context> {
7777
return self
7878
}
7979

80-
@discardableResult
8180
/// Adds multiple query operation definitions to the schema.
8281
/// - Parameter component: The query operations to add
8382
/// - Returns: This object for method chaining
83+
@discardableResult
8484
public func addQuery(
8585
@FieldComponentBuilder<Resolver, Context> _ fields: ()
8686
-> [FieldComponent<Resolver, Context>]
@@ -91,10 +91,10 @@ public final class SchemaBuilder<Resolver, Context> {
9191
return self
9292
}
9393

94-
@discardableResult
9594
/// Adds multiple mutation operation definitions to the schema.
9695
/// - Parameter component: The query operations to add
9796
/// - Returns: This object for method chaining
97+
@discardableResult
9898
public func addMutation(
9999
@FieldComponentBuilder<Resolver, Context> _ fields: ()
100100
-> [FieldComponent<Resolver, Context>]
@@ -105,10 +105,10 @@ public final class SchemaBuilder<Resolver, Context> {
105105
return self
106106
}
107107

108-
@discardableResult
109108
/// Adds multiple subscription operation definitions to the schema.
110109
/// - Parameter component: The query operations to add
111110
/// - Returns: This object for method chaining
111+
@discardableResult
112112
public func addSubscription(
113113
@FieldComponentBuilder<Resolver, Context> _ fields: ()
114114
-> [FieldComponent<Resolver, Context>]
@@ -119,10 +119,10 @@ public final class SchemaBuilder<Resolver, Context> {
119119
return self
120120
}
121121

122-
@discardableResult
123122
/// Adds multiple type, query, mutation, and subscription definitions using partial schemas to the schema.
124123
/// - Parameter partials: Partial schemas that declare types, query, mutation, and/or subscription definiton
125124
/// - Returns: Thie object for method chaining
125+
@discardableResult
126126
public func use(partials: [PartialSchema<Resolver, Context>]) -> Self {
127127
for type in partials.flatMap({ $0.types }) {
128128
typeComponents.append(type)

Tests/GraphitiTests/FederationTests/FederationOnlySchemaTests.swift

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ final class FederationOnlySchemaTests: XCTestCase {
1616
struct User: Codable {
1717
let id: String
1818

19-
func profile(context: NoContext, args: NoArguments) async throws -> Profile {
19+
func profile(context _: NoContext, args _: NoArguments) async throws -> Profile {
2020
if id == "1" {
2121
return Profile(name: "User \(id)", email: nil)
2222
} else {
@@ -30,7 +30,7 @@ final class FederationOnlySchemaTests: XCTestCase {
3030
}
3131

3232
struct FederationOnlyResolver {
33-
func user(context: NoContext, key: User.Key) async throws -> User {
33+
func user(context _: NoContext, key: User.Key) async throws -> User {
3434
User(id: key.id)
3535
}
3636
}
@@ -41,17 +41,17 @@ final class FederationOnlySchemaTests: XCTestCase {
4141
}
4242

4343
static let federatedSDL: String =
44-
"""
45-
type User @key(fields: "id") {
46-
id: String!
47-
profile: Profile!
48-
}
44+
"""
45+
type User @key(fields: "id") {
46+
id: String!
47+
profile: Profile!
48+
}
4949
50-
type Profile {
51-
name: String!
52-
email: String
53-
}
54-
"""
50+
type Profile {
51+
name: String!
52+
email: String
53+
}
54+
"""
5555

5656
override func setUpWithError() throws {
5757
let schema = try SchemaBuilder(FederationOnlyResolver.self, NoContext.self)
@@ -100,24 +100,24 @@ final class FederationOnlySchemaTests: XCTestCase {
100100
]
101101

102102
let query =
103-
"""
104-
query user($representations: [_Any!]!) {
105-
_entities(representations: $representations) {
106-
... on User {
107-
id
108-
}
109-
}
110-
}
111-
"""
103+
"""
104+
query user($representations: [_Any!]!) {
105+
_entities(representations: $representations) {
106+
... on User {
107+
id
108+
}
109+
}
110+
}
111+
"""
112112

113113
try XCTAssertEqual(
114114
execute(request: query, variables: representations),
115115
GraphQLResult(data: [
116116
"_entities": [
117117
[
118-
"id": "1234"
119-
]
120-
]
118+
"id": "1234",
119+
],
120+
],
121121
])
122122
)
123123
}
@@ -130,16 +130,16 @@ final class FederationOnlySchemaTests: XCTestCase {
130130
]
131131

132132
let query =
133-
"""
134-
query user($representations: [_Any!]!) {
135-
_entities(representations: $representations) {
136-
... on User {
137-
id
138-
profile { name, email }
139-
}
140-
}
141-
}
142-
"""
133+
"""
134+
query user($representations: [_Any!]!) {
135+
_entities(representations: $representations) {
136+
... on User {
137+
id
138+
profile { name, email }
139+
}
140+
}
141+
}
142+
"""
143143

144144
try XCTAssertEqual(
145145
execute(request: query, variables: representations),
@@ -149,10 +149,10 @@ final class FederationOnlySchemaTests: XCTestCase {
149149
"id": "1234",
150150
"profile": [
151151
"name": "User 1234",
152-
"email": "[email protected]"
153-
]
154-
]
155-
]
152+
"email": "[email protected]",
153+
],
154+
],
155+
],
156156
])
157157
)
158158
}
@@ -165,16 +165,16 @@ final class FederationOnlySchemaTests: XCTestCase {
165165
]
166166

167167
let query =
168-
"""
169-
query user($representations: [_Any!]!) {
170-
_entities(representations: $representations) {
171-
... on User {
172-
id
173-
profile { name, email }
174-
}
175-
}
176-
}
177-
"""
168+
"""
169+
query user($representations: [_Any!]!) {
170+
_entities(representations: $representations) {
171+
... on User {
172+
id
173+
profile { name, email }
174+
}
175+
}
176+
}
177+
"""
178178

179179
try XCTAssertEqual(
180180
execute(request: query, variables: representations),
@@ -184,10 +184,10 @@ final class FederationOnlySchemaTests: XCTestCase {
184184
"id": "1",
185185
"profile": [
186186
"name": "User 1",
187-
"email": .null
188-
]
189-
]
190-
]
187+
"email": .null,
188+
],
189+
],
190+
],
191191
])
192192
)
193193
}

0 commit comments

Comments
 (0)