Skip to content

Commit

Permalink
Merge pull request #146 from 3a4oT/swift-5-7
Browse files Browse the repository at this point in the history
Set Swift 5.8 as the minimum supported version
  • Loading branch information
NeedleInAJayStack authored Oct 21, 2024
2 parents d52f328 + ed2a996 commit 0dfa0d9
Show file tree
Hide file tree
Showing 10 changed files with 1,336 additions and 1,374 deletions.
16 changes: 1 addition & 15 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
swift: ["5.7", "5.8", "5.9", "5.10"]
swift: ["5.8", "5.9", "5.10"]
steps:
- uses: swift-actions/setup-swift@v2
with:
Expand All @@ -70,17 +70,3 @@ jobs:
- name: Test
run: swift test --parallel

# Swift versions older than 5.7 don't have builds for 22.04. https://www.swift.org/download/
backcompat-ubuntu-20_04:
name: Test Swift ${{ matrix.swift }} on Ubuntu 20.04
runs-on: ubuntu-20.04
strategy:
matrix:
swift: ["5.4", "5.5", "5.6"]
steps:
- uses: swift-actions/setup-swift@v2
with:
swift-version: ${{ matrix.swift }}
- uses: actions/checkout@v3
- name: Test
run: swift test --parallel
42 changes: 20 additions & 22 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
"object": {
"pins": [
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections",
"state": {
"branch": null,
"revision": "48254824bb4248676bf7ce56014ff57b142b77eb",
"version": "1.0.2"
}
},
{
"package": "swift-nio",
"repositoryURL": "https://github.com/apple/swift-nio.git",
"state": {
"branch": null,
"revision": "124119f0bb12384cef35aa041d7c3a686108722d",
"version": "2.40.0"
}
"pins" : [
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "9bf03ff58ce34478e66aaee630e491823326fd06",
"version" : "1.1.3"
}
]
},
"version": 1
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "4c4453b489cf76e6b3b0f300aba663eb78182fad",
"version" : "2.70.0"
}
}
],
"version" : 2
}
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.4
// swift-tools-version:5.8
import PackageDescription

let package = Package(
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ If you encode a `GraphQLResult` with an ordinary `JSONEncoder`, there are no gua
violating the [GraphQL spec](https://spec.graphql.org/June2018/#sec-Serialized-Map-Ordering). To preserve this order, `GraphQLResult`
should be encoded using the `GraphQLJSONEncoder` provided by this package.

## Support

This package supports Swift versions in [alignment with Swift NIO](https://github.com/apple/swift-nio?tab=readme-ov-file#swift-versions).

## Contributing

If you think you have found a security vulnerability, please follow the
Expand Down
262 changes: 129 additions & 133 deletions Sources/GraphQL/GraphQL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,137 +279,133 @@ public func graphqlSubscribe(

// MARK: Async/Await

#if compiler(>=5.5) && canImport(_Concurrency)

@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
/// This is the primary entry point function for fulfilling GraphQL operations
/// by parsing, validating, and executing a GraphQL document along side a
/// GraphQL schema.
///
/// More sophisticated GraphQL servers, such as those which persist queries,
/// may wish to separate the validation and execution phases to a static time
/// tooling step, and a server runtime step.
///
/// - parameter queryStrategy: The field execution strategy to use for query requests
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
/// requests
/// - parameter instrumentation: The instrumentation implementation to call during the
/// parsing, validating, execution, and field resolution stages.
/// - parameter schema: The GraphQL type system to use when validating and
/// executing a query.
/// - parameter request: A GraphQL language formatted string representing the
/// requested operation.
/// - parameter rootValue: The value provided as the first argument to resolver
/// functions on the top level type (e.g. the query object type).
/// - parameter contextValue: A context value provided to all resolver functions
/// functions
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
/// variables defined in the `request`.
/// - parameter operationName: The name of the operation to use if `request` contains
/// multiple possible operations. Can be omitted if `request` contains only one operation.
///
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
///
/// - returns: returns a `Map` dictionary containing the result of the query inside the key
/// `data` and any validation or execution errors inside the key `errors`. The value of `data`
/// might be `null` if, for example, the query is invalid. It's possible to have both `data` and
/// `errors` if an error occurs only in a specific field. If that happens the value of that
/// field will be `null` and there will be an error inside `errors` specifying the reason for
/// the failure and the path of the failed field.
public func graphql(
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
instrumentation: Instrumentation = NoOpInstrumentation,
schema: GraphQLSchema,
request: String,
rootValue: Any = (),
context: Any = (),
eventLoopGroup: EventLoopGroup,
variableValues: [String: Map] = [:],
operationName: String? = nil
) async throws -> GraphQLResult {
return try await graphql(
queryStrategy: queryStrategy,
mutationStrategy: mutationStrategy,
subscriptionStrategy: subscriptionStrategy,
instrumentation: instrumentation,
schema: schema,
request: request,
rootValue: rootValue,
context: context,
eventLoopGroup: eventLoopGroup,
variableValues: variableValues,
operationName: operationName
).get()
}

@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
/// This is the primary entry point function for fulfilling GraphQL subscription
/// operations by parsing, validating, and executing a GraphQL subscription
/// document along side a GraphQL schema.
///
/// More sophisticated GraphQL servers, such as those which persist queries,
/// may wish to separate the validation and execution phases to a static time
/// tooling step, and a server runtime step.
///
/// - parameter queryStrategy: The field execution strategy to use for query requests
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
/// requests
/// - parameter instrumentation: The instrumentation implementation to call during the
/// parsing, validating, execution, and field resolution stages.
/// - parameter schema: The GraphQL type system to use when validating and
/// executing a query.
/// - parameter request: A GraphQL language formatted string representing the
/// requested operation.
/// - parameter rootValue: The value provided as the first argument to resolver
/// functions on the top level type (e.g. the query object type).
/// - parameter contextValue: A context value provided to all resolver functions
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
/// variables defined in the `request`.
/// - parameter operationName: The name of the operation to use if `request` contains
/// multiple possible operations. Can be omitted if `request` contains only one operation.
///
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
///
/// - returns: returns a SubscriptionResult containing the subscription observable inside the
/// key `observable` and any validation or execution errors inside the key `errors`. The
/// value of `observable` might be `null` if, for example, the query is invalid. It's not
/// possible to have both `observable` and `errors`. The observable payloads are
/// GraphQLResults which contain the result of the query inside the key `data` and any
/// validation or execution errors inside the key `errors`. The value of `data` might be `null`.
/// It's possible to have both `data` and `errors` if an error occurs only in a specific field.
/// If that happens the value of that field will be `null` and there
/// will be an error inside `errors` specifying the reason for the failure and the path of the
/// failed field.
public func graphqlSubscribe(
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
instrumentation: Instrumentation = NoOpInstrumentation,
schema: GraphQLSchema,
request: String,
rootValue: Any = (),
context: Any = (),
eventLoopGroup: EventLoopGroup,
variableValues: [String: Map] = [:],
operationName: String? = nil
) async throws -> SubscriptionResult {
return try await graphqlSubscribe(
queryStrategy: queryStrategy,
mutationStrategy: mutationStrategy,
subscriptionStrategy: subscriptionStrategy,
instrumentation: instrumentation,
schema: schema,
request: request,
rootValue: rootValue,
context: context,
eventLoopGroup: eventLoopGroup,
variableValues: variableValues,
operationName: operationName
).get()
}
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
/// This is the primary entry point function for fulfilling GraphQL operations
/// by parsing, validating, and executing a GraphQL document along side a
/// GraphQL schema.
///
/// More sophisticated GraphQL servers, such as those which persist queries,
/// may wish to separate the validation and execution phases to a static time
/// tooling step, and a server runtime step.
///
/// - parameter queryStrategy: The field execution strategy to use for query requests
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
/// requests
/// - parameter instrumentation: The instrumentation implementation to call during the
/// parsing, validating, execution, and field resolution stages.
/// - parameter schema: The GraphQL type system to use when validating and
/// executing a query.
/// - parameter request: A GraphQL language formatted string representing the
/// requested operation.
/// - parameter rootValue: The value provided as the first argument to resolver
/// functions on the top level type (e.g. the query object type).
/// - parameter contextValue: A context value provided to all resolver functions
/// functions
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
/// variables defined in the `request`.
/// - parameter operationName: The name of the operation to use if `request` contains
/// multiple possible operations. Can be omitted if `request` contains only one operation.
///
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
///
/// - returns: returns a `Map` dictionary containing the result of the query inside the key
/// `data` and any validation or execution errors inside the key `errors`. The value of `data`
/// might be `null` if, for example, the query is invalid. It's possible to have both `data` and
/// `errors` if an error occurs only in a specific field. If that happens the value of that
/// field will be `null` and there will be an error inside `errors` specifying the reason for
/// the failure and the path of the failed field.
public func graphql(
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
instrumentation: Instrumentation = NoOpInstrumentation,
schema: GraphQLSchema,
request: String,
rootValue: Any = (),
context: Any = (),
eventLoopGroup: EventLoopGroup,
variableValues: [String: Map] = [:],
operationName: String? = nil
) async throws -> GraphQLResult {
return try await graphql(
queryStrategy: queryStrategy,
mutationStrategy: mutationStrategy,
subscriptionStrategy: subscriptionStrategy,
instrumentation: instrumentation,
schema: schema,
request: request,
rootValue: rootValue,
context: context,
eventLoopGroup: eventLoopGroup,
variableValues: variableValues,
operationName: operationName
).get()
}

#endif
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
/// This is the primary entry point function for fulfilling GraphQL subscription
/// operations by parsing, validating, and executing a GraphQL subscription
/// document along side a GraphQL schema.
///
/// More sophisticated GraphQL servers, such as those which persist queries,
/// may wish to separate the validation and execution phases to a static time
/// tooling step, and a server runtime step.
///
/// - parameter queryStrategy: The field execution strategy to use for query requests
/// - parameter mutationStrategy: The field execution strategy to use for mutation requests
/// - parameter subscriptionStrategy: The field execution strategy to use for subscription
/// requests
/// - parameter instrumentation: The instrumentation implementation to call during the
/// parsing, validating, execution, and field resolution stages.
/// - parameter schema: The GraphQL type system to use when validating and
/// executing a query.
/// - parameter request: A GraphQL language formatted string representing the
/// requested operation.
/// - parameter rootValue: The value provided as the first argument to resolver
/// functions on the top level type (e.g. the query object type).
/// - parameter contextValue: A context value provided to all resolver functions
/// - parameter variableValues: A mapping of variable name to runtime value to use for all
/// variables defined in the `request`.
/// - parameter operationName: The name of the operation to use if `request` contains
/// multiple possible operations. Can be omitted if `request` contains only one operation.
///
/// - throws: throws GraphQLError if an error occurs while parsing the `request`.
///
/// - returns: returns a SubscriptionResult containing the subscription observable inside the
/// key `observable` and any validation or execution errors inside the key `errors`. The
/// value of `observable` might be `null` if, for example, the query is invalid. It's not
/// possible to have both `observable` and `errors`. The observable payloads are
/// GraphQLResults which contain the result of the query inside the key `data` and any
/// validation or execution errors inside the key `errors`. The value of `data` might be `null`.
/// It's possible to have both `data` and `errors` if an error occurs only in a specific field.
/// If that happens the value of that field will be `null` and there
/// will be an error inside `errors` specifying the reason for the failure and the path of the
/// failed field.
public func graphqlSubscribe(
queryStrategy: QueryFieldExecutionStrategy = SerialFieldExecutionStrategy(),
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
subscriptionStrategy: SubscriptionFieldExecutionStrategy = SerialFieldExecutionStrategy(),
instrumentation: Instrumentation = NoOpInstrumentation,
schema: GraphQLSchema,
request: String,
rootValue: Any = (),
context: Any = (),
eventLoopGroup: EventLoopGroup,
variableValues: [String: Map] = [:],
operationName: String? = nil
) async throws -> SubscriptionResult {
return try await graphqlSubscribe(
queryStrategy: queryStrategy,
mutationStrategy: mutationStrategy,
subscriptionStrategy: subscriptionStrategy,
instrumentation: instrumentation,
schema: schema,
request: request,
rootValue: rootValue,
context: context,
eventLoopGroup: eventLoopGroup,
variableValues: variableValues,
operationName: operationName
).get()
}
Loading

0 comments on commit 0dfa0d9

Please sign in to comment.