Skip to content

Commit b481087

Browse files
feat: Deprecates specifying execution strategies
1 parent 53f52cb commit b481087

File tree

2 files changed

+122
-4
lines changed

2 files changed

+122
-4
lines changed

Sources/GraphQL/GraphQL.swift

+122
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,33 @@ public typealias SubscriptionEventStream = EventStream<Future<GraphQLResult>>
8686
/// an error occurs only in a specific field. If that happens the value of that field will be `null`
8787
/// and there will be an error inside `errors` specifying the reason for the failure and the path of
8888
/// the failed field.
89+
public func graphql(
90+
schema: GraphQLSchema,
91+
request: String,
92+
rootValue: Any = (),
93+
context: Any = (),
94+
eventLoopGroup: EventLoopGroup,
95+
variableValues: [String: Map] = [:],
96+
operationName: String? = nil,
97+
validationRules: [(ValidationContext) -> Visitor] = []
98+
) throws -> Future<GraphQLResult> {
99+
return try graphql(
100+
queryStrategy: ConcurrentFieldExecutionStrategy(),
101+
mutationStrategy: SerialFieldExecutionStrategy(),
102+
subscriptionStrategy: ConcurrentFieldExecutionStrategy(),
103+
instrumentation: NoOpInstrumentation,
104+
validationRules: validationRules,
105+
schema: schema,
106+
request: request,
107+
rootValue: rootValue,
108+
context: context,
109+
eventLoopGroup: eventLoopGroup,
110+
variableValues: variableValues,
111+
operationName: operationName
112+
)
113+
}
114+
115+
@available(*, deprecated, message: "Specifying exeuction strategies and instrumentation will be removed in a future version.")
89116
public func graphql(
90117
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
91118
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -155,6 +182,31 @@ public func graphql(
155182
/// an error occurs only in a specific field. If that happens the value of that field will be `null`
156183
/// and there will be an error inside `errors` specifying the reason for the failure and the path of
157184
/// the failed field.
185+
public func graphql<Retrieval: PersistedQueryRetrieval>(
186+
queryRetrieval: Retrieval,
187+
queryId: Retrieval.Id,
188+
rootValue: Any = (),
189+
context: Any = (),
190+
eventLoopGroup: EventLoopGroup,
191+
variableValues: [String: Map] = [:],
192+
operationName: String? = nil
193+
) throws -> Future<GraphQLResult> {
194+
return try graphql(
195+
queryStrategy: ConcurrentFieldExecutionStrategy(),
196+
mutationStrategy: SerialFieldExecutionStrategy(),
197+
subscriptionStrategy: ConcurrentFieldExecutionStrategy(),
198+
instrumentation: NoOpInstrumentation,
199+
queryRetrieval: queryRetrieval,
200+
queryId: queryId,
201+
rootValue: rootValue,
202+
context: context,
203+
eventLoopGroup: eventLoopGroup,
204+
variableValues: variableValues,
205+
operationName: operationName
206+
)
207+
}
208+
209+
@available(*, deprecated, message: "Specifying exeuction strategies and instrumentation will be removed in a future version.")
158210
public func graphql<Retrieval: PersistedQueryRetrieval>(
159211
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
160212
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -229,6 +281,32 @@ public func graphql<Retrieval: PersistedQueryRetrieval>(
229281
/// that happens the value of that field will be `null` and there
230282
/// will be an error inside `errors` specifying the reason for the failure and the path of the
231283
/// failed field.
284+
public func graphqlSubscribe(
285+
schema: GraphQLSchema,
286+
request: String,
287+
rootValue: Any = (),
288+
context: Any = (),
289+
eventLoopGroup: EventLoopGroup,
290+
variableValues: [String: Map] = [:],
291+
operationName: String? = nil,
292+
validationRules: [(ValidationContext) -> Visitor] = []
293+
) throws -> Future<SubscriptionResult> {
294+
return try graphqlSubscribe(
295+
queryStrategy: ConcurrentFieldExecutionStrategy(),
296+
mutationStrategy: SerialFieldExecutionStrategy(),
297+
subscriptionStrategy: ConcurrentFieldExecutionStrategy(),
298+
instrumentation: NoOpInstrumentation,
299+
schema: schema,
300+
request: request,
301+
rootValue: rootValue,
302+
context: context,
303+
eventLoopGroup: eventLoopGroup,
304+
variableValues: variableValues,
305+
operationName: operationName
306+
)
307+
}
308+
309+
@available(*, deprecated, message: "Specifying exeuction strategies and instrumentation will be removed in a future version.")
232310
public func graphqlSubscribe(
233311
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
234312
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -310,6 +388,28 @@ public func graphqlSubscribe(
310388
/// field will be `null` and there will be an error inside `errors` specifying the reason for
311389
/// the failure and the path of the failed field.
312390
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
391+
public func graphql(
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 -> GraphQLResult {
400+
return try await graphql(
401+
schema: schema,
402+
request: request,
403+
rootValue: rootValue,
404+
context: context,
405+
eventLoopGroup: eventLoopGroup,
406+
variableValues: variableValues,
407+
operationName: operationName
408+
).get()
409+
}
410+
411+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
412+
@available(*, deprecated, message: "Specifying exeuction strategies and instrumentation will be removed in a future version.")
313413
public func graphql(
314414
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
315415
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -377,6 +477,28 @@ public func graphql(
377477
/// will be an error inside `errors` specifying the reason for the failure and the path of the
378478
/// failed field.
379479
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
480+
public func graphqlSubscribe(
481+
schema: GraphQLSchema,
482+
request: String,
483+
rootValue: Any = (),
484+
context: Any = (),
485+
eventLoopGroup: EventLoopGroup,
486+
variableValues: [String: Map] = [:],
487+
operationName: String? = nil
488+
) async throws -> SubscriptionResult {
489+
return try await graphqlSubscribe(
490+
schema: schema,
491+
request: request,
492+
rootValue: rootValue,
493+
context: context,
494+
eventLoopGroup: eventLoopGroup,
495+
variableValues: variableValues,
496+
operationName: operationName
497+
).get()
498+
}
499+
500+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
501+
@available(*, deprecated, message: "Specifying exeuction strategies and instrumentation will be removed in a future version.")
380502
public func graphqlSubscribe(
381503
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
382504
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),

Tests/GraphQLTests/SubscriptionTests/SubscriptionSchema.swift

-4
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,6 @@ func createSubscription(
193193
variableValues: [String: Map] = [:]
194194
) throws -> SubscriptionEventStream {
195195
let result = try graphqlSubscribe(
196-
queryStrategy: SerialFieldExecutionStrategy(),
197-
mutationStrategy: SerialFieldExecutionStrategy(),
198-
subscriptionStrategy: SerialFieldExecutionStrategy(),
199-
instrumentation: NoOpInstrumentation,
200196
schema: schema,
201197
request: query,
202198
rootValue: (),

0 commit comments

Comments
 (0)