Skip to content

Commit 0dfa0d9

Browse files
Merge pull request #146 from 3a4oT/swift-5-7
Set Swift 5.8 as the minimum supported version
2 parents d52f328 + ed2a996 commit 0dfa0d9

File tree

10 files changed

+1336
-1374
lines changed

10 files changed

+1336
-1374
lines changed

.github/workflows/build.yml

+1-15
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
runs-on: ubuntu-22.04
6262
strategy:
6363
matrix:
64-
swift: ["5.7", "5.8", "5.9", "5.10"]
64+
swift: ["5.8", "5.9", "5.10"]
6565
steps:
6666
- uses: swift-actions/setup-swift@v2
6767
with:
@@ -70,17 +70,3 @@ jobs:
7070
- name: Test
7171
run: swift test --parallel
7272

73-
# Swift versions older than 5.7 don't have builds for 22.04. https://www.swift.org/download/
74-
backcompat-ubuntu-20_04:
75-
name: Test Swift ${{ matrix.swift }} on Ubuntu 20.04
76-
runs-on: ubuntu-20.04
77-
strategy:
78-
matrix:
79-
swift: ["5.4", "5.5", "5.6"]
80-
steps:
81-
- uses: swift-actions/setup-swift@v2
82-
with:
83-
swift-version: ${{ matrix.swift }}
84-
- uses: actions/checkout@v3
85-
- name: Test
86-
run: swift test --parallel

Package.resolved

+20-22
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
11
{
2-
"object": {
3-
"pins": [
4-
{
5-
"package": "swift-collections",
6-
"repositoryURL": "https://github.com/apple/swift-collections",
7-
"state": {
8-
"branch": null,
9-
"revision": "48254824bb4248676bf7ce56014ff57b142b77eb",
10-
"version": "1.0.2"
11-
}
12-
},
13-
{
14-
"package": "swift-nio",
15-
"repositoryURL": "https://github.com/apple/swift-nio.git",
16-
"state": {
17-
"branch": null,
18-
"revision": "124119f0bb12384cef35aa041d7c3a686108722d",
19-
"version": "2.40.0"
20-
}
2+
"pins" : [
3+
{
4+
"identity" : "swift-collections",
5+
"kind" : "remoteSourceControl",
6+
"location" : "https://github.com/apple/swift-collections",
7+
"state" : {
8+
"revision" : "9bf03ff58ce34478e66aaee630e491823326fd06",
9+
"version" : "1.1.3"
2110
}
22-
]
23-
},
24-
"version": 1
11+
},
12+
{
13+
"identity" : "swift-nio",
14+
"kind" : "remoteSourceControl",
15+
"location" : "https://github.com/apple/swift-nio.git",
16+
"state" : {
17+
"revision" : "4c4453b489cf76e6b3b0f300aba663eb78182fad",
18+
"version" : "2.70.0"
19+
}
20+
}
21+
],
22+
"version" : 2
2523
}

Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:5.4
1+
// swift-tools-version:5.8
22
import PackageDescription
33

44
let package = Package(

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ If you encode a `GraphQLResult` with an ordinary `JSONEncoder`, there are no gua
119119
violating the [GraphQL spec](https://spec.graphql.org/June2018/#sec-Serialized-Map-Ordering). To preserve this order, `GraphQLResult`
120120
should be encoded using the `GraphQLJSONEncoder` provided by this package.
121121

122+
## Support
123+
124+
This package supports Swift versions in [alignment with Swift NIO](https://github.com/apple/swift-nio?tab=readme-ov-file#swift-versions).
125+
122126
## Contributing
123127

124128
If you think you have found a security vulnerability, please follow the

Sources/GraphQL/GraphQL.swift

+129-133
Original file line numberDiff line numberDiff line change
@@ -279,137 +279,133 @@ public func graphqlSubscribe(
279279

280280
// MARK: Async/Await
281281

282-
#if compiler(>=5.5) && canImport(_Concurrency)
283-
284-
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
285-
/// This is the primary entry point function for fulfilling GraphQL operations
286-
/// by parsing, validating, and executing a GraphQL document along side a
287-
/// GraphQL schema.
288-
///
289-
/// More sophisticated GraphQL servers, such as those which persist queries,
290-
/// may wish to separate the validation and execution phases to a static time
291-
/// tooling step, and a server runtime step.
292-
///
293-
/// - parameter queryStrategy: The field execution strategy to use for query requests
294-
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
295-
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
296-
/// requests
297-
/// - parameter instrumentation: The instrumentation implementation to call during the
298-
/// parsing, validating, execution, and field resolution stages.
299-
/// - parameter schema: The GraphQL type system to use when validating and
300-
/// executing a query.
301-
/// - parameter request: A GraphQL language formatted string representing the
302-
/// requested operation.
303-
/// - parameter rootValue: The value provided as the first argument to resolver
304-
/// functions on the top level type (e.g. the query object type).
305-
/// - parameter contextValue: A context value provided to all resolver functions
306-
/// functions
307-
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
308-
/// variables defined in the `request`.
309-
/// - parameter operationName: The name of the operation to use if `request` contains
310-
/// multiple possible operations. Can be omitted if `request` contains only one operation.
311-
///
312-
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
313-
///
314-
/// - returns: returns a `Map` dictionary containing the result of the query inside the key
315-
/// `data` and any validation or execution errors inside the key `errors`. The value of `data`
316-
/// might be `null` if, for example, the query is invalid. It's possible to have both `data` and
317-
/// `errors` if an error occurs only in a specific field. If that happens the value of that
318-
/// field will be `null` and there will be an error inside `errors` specifying the reason for
319-
/// the failure and the path of the failed field.
320-
public func graphql(
321-
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
322-
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
323-
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
324-
instrumentation: Instrumentation = NoOpInstrumentation,
325-
schema: GraphQLSchema,
326-
request: String,
327-
rootValue: Any = (),
328-
context: Any = (),
329-
eventLoopGroup: EventLoopGroup,
330-
variableValues: [String: Map] = [:],
331-
operationName: String? = nil
332-
) async throws -> GraphQLResult {
333-
return try await graphql(
334-
queryStrategy: queryStrategy,
335-
mutationStrategy: mutationStrategy,
336-
subscriptionStrategy: subscriptionStrategy,
337-
instrumentation: instrumentation,
338-
schema: schema,
339-
request: request,
340-
rootValue: rootValue,
341-
context: context,
342-
eventLoopGroup: eventLoopGroup,
343-
variableValues: variableValues,
344-
operationName: operationName
345-
).get()
346-
}
347-
348-
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
349-
/// This is the primary entry point function for fulfilling GraphQL subscription
350-
/// operations by parsing, validating, and executing a GraphQL subscription
351-
/// document along side a GraphQL schema.
352-
///
353-
/// More sophisticated GraphQL servers, such as those which persist queries,
354-
/// may wish to separate the validation and execution phases to a static time
355-
/// tooling step, and a server runtime step.
356-
///
357-
/// - parameter queryStrategy: The field execution strategy to use for query requests
358-
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
359-
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
360-
/// requests
361-
/// - parameter instrumentation: The instrumentation implementation to call during the
362-
/// parsing, validating, execution, and field resolution stages.
363-
/// - parameter schema: The GraphQL type system to use when validating and
364-
/// executing a query.
365-
/// - parameter request: A GraphQL language formatted string representing the
366-
/// requested operation.
367-
/// - parameter rootValue: The value provided as the first argument to resolver
368-
/// functions on the top level type (e.g. the query object type).
369-
/// - parameter contextValue: A context value provided to all resolver functions
370-
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
371-
/// variables defined in the `request`.
372-
/// - parameter operationName: The name of the operation to use if `request` contains
373-
/// multiple possible operations. Can be omitted if `request` contains only one operation.
374-
///
375-
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
376-
///
377-
/// - returns: returns a SubscriptionResult containing the subscription observable inside the
378-
/// key `observable` and any validation or execution errors inside the key `errors`. The
379-
/// value of `observable` might be `null` if, for example, the query is invalid. It's not
380-
/// possible to have both `observable` and `errors`. The observable payloads are
381-
/// GraphQLResults which contain the result of the query inside the key `data` and any
382-
/// validation or execution errors inside the key `errors`. The value of `data` might be `null`.
383-
/// It's possible to have both `data` and `errors` if an error occurs only in a specific field.
384-
/// If that happens the value of that field will be `null` and there
385-
/// will be an error inside `errors` specifying the reason for the failure and the path of the
386-
/// failed field.
387-
public func graphqlSubscribe(
388-
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
389-
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
390-
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
391-
instrumentation: Instrumentation = NoOpInstrumentation,
392-
schema: GraphQLSchema,
393-
request: String,
394-
rootValue: Any = (),
395-
context: Any = (),
396-
eventLoopGroup: EventLoopGroup,
397-
variableValues: [String: Map] = [:],
398-
operationName: String? = nil
399-
) async throws -> SubscriptionResult {
400-
return try await graphqlSubscribe(
401-
queryStrategy: queryStrategy,
402-
mutationStrategy: mutationStrategy,
403-
subscriptionStrategy: subscriptionStrategy,
404-
instrumentation: instrumentation,
405-
schema: schema,
406-
request: request,
407-
rootValue: rootValue,
408-
context: context,
409-
eventLoopGroup: eventLoopGroup,
410-
variableValues: variableValues,
411-
operationName: operationName
412-
).get()
413-
}
282+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
283+
/// This is the primary entry point function for fulfilling GraphQL operations
284+
/// by parsing, validating, and executing a GraphQL document along side a
285+
/// GraphQL schema.
286+
///
287+
/// More sophisticated GraphQL servers, such as those which persist queries,
288+
/// may wish to separate the validation and execution phases to a static time
289+
/// tooling step, and a server runtime step.
290+
///
291+
/// - parameter queryStrategy: The field execution strategy to use for query requests
292+
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
293+
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
294+
/// requests
295+
/// - parameter instrumentation: The instrumentation implementation to call during the
296+
/// parsing, validating, execution, and field resolution stages.
297+
/// - parameter schema: The GraphQL type system to use when validating and
298+
/// executing a query.
299+
/// - parameter request: A GraphQL language formatted string representing the
300+
/// requested operation.
301+
/// - parameter rootValue: The value provided as the first argument to resolver
302+
/// functions on the top level type (e.g. the query object type).
303+
/// - parameter contextValue: A context value provided to all resolver functions
304+
/// functions
305+
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
306+
/// variables defined in the `request`.
307+
/// - parameter operationName: The name of the operation to use if `request` contains
308+
/// multiple possible operations. Can be omitted if `request` contains only one operation.
309+
///
310+
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
311+
///
312+
/// - returns: returns a `Map` dictionary containing the result of the query inside the key
313+
/// `data` and any validation or execution errors inside the key `errors`. The value of `data`
314+
/// might be `null` if, for example, the query is invalid. It's possible to have both `data` and
315+
/// `errors` if an error occurs only in a specific field. If that happens the value of that
316+
/// field will be `null` and there will be an error inside `errors` specifying the reason for
317+
/// the failure and the path of the failed field.
318+
public func graphql(
319+
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
320+
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
321+
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
322+
instrumentation: Instrumentation = NoOpInstrumentation,
323+
schema: GraphQLSchema,
324+
request: String,
325+
rootValue: Any = (),
326+
context: Any = (),
327+
eventLoopGroup: EventLoopGroup,
328+
variableValues: [String: Map] = [:],
329+
operationName: String? = nil
330+
) async throws -> GraphQLResult {
331+
return try await graphql(
332+
queryStrategy: queryStrategy,
333+
mutationStrategy: mutationStrategy,
334+
subscriptionStrategy: subscriptionStrategy,
335+
instrumentation: instrumentation,
336+
schema: schema,
337+
request: request,
338+
rootValue: rootValue,
339+
context: context,
340+
eventLoopGroup: eventLoopGroup,
341+
variableValues: variableValues,
342+
operationName: operationName
343+
).get()
344+
}
414345

415-
#endif
346+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
347+
/// This is the primary entry point function for fulfilling GraphQL subscription
348+
/// operations by parsing, validating, and executing a GraphQL subscription
349+
/// document along side a GraphQL schema.
350+
///
351+
/// More sophisticated GraphQL servers, such as those which persist queries,
352+
/// may wish to separate the validation and execution phases to a static time
353+
/// tooling step, and a server runtime step.
354+
///
355+
/// - parameter queryStrategy: The field execution strategy to use for query requests
356+
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
357+
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
358+
/// requests
359+
/// - parameter instrumentation: The instrumentation implementation to call during the
360+
/// parsing, validating, execution, and field resolution stages.
361+
/// - parameter schema: The GraphQL type system to use when validating and
362+
/// executing a query.
363+
/// - parameter request: A GraphQL language formatted string representing the
364+
/// requested operation.
365+
/// - parameter rootValue: The value provided as the first argument to resolver
366+
/// functions on the top level type (e.g. the query object type).
367+
/// - parameter contextValue: A context value provided to all resolver functions
368+
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
369+
/// variables defined in the `request`.
370+
/// - parameter operationName: The name of the operation to use if `request` contains
371+
/// multiple possible operations. Can be omitted if `request` contains only one operation.
372+
///
373+
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
374+
///
375+
/// - returns: returns a SubscriptionResult containing the subscription observable inside the
376+
/// key `observable` and any validation or execution errors inside the key `errors`. The
377+
/// value of `observable` might be `null` if, for example, the query is invalid. It's not
378+
/// possible to have both `observable` and `errors`. The observable payloads are
379+
/// GraphQLResults which contain the result of the query inside the key `data` and any
380+
/// validation or execution errors inside the key `errors`. The value of `data` might be `null`.
381+
/// It's possible to have both `data` and `errors` if an error occurs only in a specific field.
382+
/// If that happens the value of that field will be `null` and there
383+
/// will be an error inside `errors` specifying the reason for the failure and the path of the
384+
/// failed field.
385+
public func graphqlSubscribe(
386+
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
387+
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
388+
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
389+
instrumentation: Instrumentation = NoOpInstrumentation,
390+
schema: GraphQLSchema,
391+
request: String,
392+
rootValue: Any = (),
393+
context: Any = (),
394+
eventLoopGroup: EventLoopGroup,
395+
variableValues: [String: Map] = [:],
396+
operationName: String? = nil
397+
) async throws -> SubscriptionResult {
398+
return try await graphqlSubscribe(
399+
queryStrategy: queryStrategy,
400+
mutationStrategy: mutationStrategy,
401+
subscriptionStrategy: subscriptionStrategy,
402+
instrumentation: instrumentation,
403+
schema: schema,
404+
request: request,
405+
rootValue: rootValue,
406+
context: context,
407+
eventLoopGroup: eventLoopGroup,
408+
variableValues: variableValues,
409+
operationName: operationName
410+
).get()
411+
}

0 commit comments

Comments
 (0)