You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This removes the NIO dependency. It is breaking because it removes all Swift NIO-isms that were present in the public APIs (like EventLoopFuture and EventLoopGroup argument/return types).
Copy file name to clipboardExpand all lines: README.md
+9-33Lines changed: 9 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
# Graphiti
1
+
# Graphiti
2
2
3
3
Graphiti is a Swift library for building GraphQL schemas fast, safely and easily.
4
4
@@ -86,7 +86,7 @@ struct MessageAPI : API {
86
86
let resolver: Resolver
87
87
let schema: Schema<Resolver, Context>
88
88
}
89
-
89
+
90
90
let api =MessageAPI(
91
91
resolver: Resolver()
92
92
schema:try! Schema<Resolver, Context> {
@@ -124,7 +124,7 @@ let api = MessageAPI(
124
124
resolver: Resolver()
125
125
schema: schema
126
126
)
127
-
```
127
+
```
128
128
129
129
</details>
130
130
<details>
@@ -136,7 +136,7 @@ final class ChatSchema: PartialSchema<Resolver, Context> {
136
136
publicoverridevar types: Types {
137
137
Type(Message.self) {
138
138
Field("content", at: \.content)
139
-
}
139
+
}
140
140
}
141
141
142
142
@FieldDefinitions
@@ -152,7 +152,7 @@ let api = MessageAPI(
152
152
resolver: Resolver()
153
153
schema: schema
154
154
)
155
-
```
155
+
```
156
156
157
157
</details>
158
158
@@ -164,7 +164,7 @@ let chatSchema = PartialSchema<Resolver, Context>(
164
164
types: {
165
165
Type(Message.self) {
166
166
Field("content", at: \.content)
167
-
}
167
+
}
168
168
},
169
169
query: {
170
170
Field("message", at: Resolver.message)
@@ -178,7 +178,7 @@ let api = MessageAPI(
178
178
resolver: Resolver()
179
179
schema: schema
180
180
)
181
-
```
181
+
```
182
182
183
183
</details>
184
184
@@ -190,20 +190,10 @@ let api = MessageAPI(
190
190
191
191
#### Querying
192
192
193
-
To query the schema we need to pass in a NIO EventLoopGroup to feed the execute function alongside the query itself.
194
-
195
193
```swift
196
-
importNIO
197
-
198
-
let group =MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
199
-
defer {
200
-
try? group.syncShutdownGracefully()
201
-
}
202
-
203
194
let result =tryawait api.execute(
204
195
request: "{ message { content } }",
205
-
context: Context(),
206
-
on: group
196
+
context: Context()
207
197
)
208
198
print(result)
209
199
```
@@ -228,27 +218,13 @@ struct Resolver {
228
218
}
229
219
```
230
220
231
-
#### NIO resolvers
232
-
233
-
The resolver functions also support `NIO`-style concurrency. To do so, just add one more parameter with type `EventLoopGroup` to the resolver function and change the return type to `EventLoopFuture<YouReturnType>`. Don't forget to import NIO.
This library supports GraphQL subscriptions, and supports them through the Swift Concurrency `AsyncThrowingStream` type. See the [Usage Guide](UsageGuide.md#subscriptions) for details.
248
224
249
225
If you are unable to use Swift Concurrency, you must create a concrete subclass of the `EventStream` class that implements event streaming
250
226
functionality. If you don't feel like creating a subclass yourself, you can use the [GraphQLRxSwift](https://github.com/GraphQLSwift/GraphQLRxSwift) repository
251
-
to integrate [RxSwift](https://github.com/ReactiveX/RxSwift) observables out-of-the-box. Or you can use that repository as a reference to connect a different
227
+
to integrate [RxSwift](https://github.com/ReactiveX/RxSwift) observables out-of-the-box. Or you can use that repository as a reference to connect a different
252
228
stream library like [ReactiveSwift](https://github.com/ReactiveCocoa/ReactiveSwift), [OpenCombine](https://github.com/OpenCombine/OpenCombine), or
0 commit comments