Skip to content

Commit b6afc7d

Browse files
feat!: Uses swift concurrency under the hood
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).
1 parent bd5419f commit b6afc7d

28 files changed

+1094
-1795
lines changed

Package.resolved

Lines changed: 0 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ import PackageDescription
33

44
let package = Package(
55
name: "GraphQL",
6+
platforms: [.macOS(.v10_15), .iOS(.v13), .tvOS(.v13), .watchOS(.v6)],
67
products: [
78
.library(name: "GraphQL", targets: ["GraphQL"]),
89
],
910
dependencies: [
10-
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.10.1")),
1111
.package(url: "https://github.com/apple/swift-collections", .upToNextMajor(from: "1.0.0")),
1212
],
1313
targets: [
1414
.target(
1515
name: "GraphQL",
1616
dependencies: [
17-
.product(name: "NIO", package: "swift-nio"),
1817
.product(name: "OrderedCollections", package: "swift-collections"),
1918
]
2019
),

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ Once a schema has been defined queries may be executed against it using the glob
4545
```swift
4646
let result = try await graphql(
4747
schema: schema,
48-
request: "{ hello }",
49-
eventLoopGroup: eventLoopGroup
48+
request: "{ hello }"
5049
)
5150
```
5251

@@ -59,7 +58,7 @@ The result of this query is a `GraphQLResult` that encodes to the following JSON
5958
### Subscription
6059

6160
This package supports GraphQL subscription, but until the integration of `AsyncSequence` in Swift 5.5 the standard Swift library did not
62-
provide an event-stream construct. For historical reasons and backwards compatibility, this library implements subscriptions using an
61+
provide an event-stream construct. For historical reasons and backwards compatibility, this library implements subscriptions using an
6362
`EventStream` protocol that nearly every asynchronous stream implementation can conform to.
6463

6564
To create a subscription field in a GraphQL schema, use the `subscribe` resolver that returns an `EventStream`. You must also provide a
@@ -70,7 +69,7 @@ let schema = try GraphQLSchema(
7069
subscribe: GraphQLObjectType(
7170
name: "Subscribe",
7271
fields: [
73-
"hello": GraphQLField(
72+
"hello": GraphQLField(
7473
type: GraphQLString,
7574
resolve: { eventResult, _, _, _, _ in // Defines how to transform each event when it occurs
7675
return eventResult
@@ -116,7 +115,7 @@ The example above assumes that your environment has access to Swift Concurrency.
116115

117116
## Encoding Results
118117

119-
If you encode a `GraphQLResult` with an ordinary `JSONEncoder`, there are no guarantees that the field order will match the query,
118+
If you encode a `GraphQLResult` with an ordinary `JSONEncoder`, there are no guarantees that the field order will match the query,
120119
violating the [GraphQL spec](https://spec.graphql.org/June2018/#sec-Serialized-Map-Ordering). To preserve this order, `GraphQLResult`
121120
should be encoded using the `GraphQLJSONEncoder` provided by this package.
122121

@@ -140,7 +139,7 @@ To format your code, install `swiftformat` and run:
140139

141140
```bash
142141
swiftformat .
143-
```
142+
```
144143

145144
Most of this repo mirrors the structure of
146145
(the canonical GraphQL implementation written in Javascript/Typescript)[https://github.com/graphql/graphql-js]. If there is any feature

0 commit comments

Comments
 (0)