Skip to content

Commit 24b5606

Browse files
feat: Deprecates specifying execution strategies
1 parent 308ab97 commit 24b5606

File tree

2 files changed

+143
-4
lines changed

2 files changed

+143
-4
lines changed

Sources/GraphQL/GraphQL.swift

+143
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,37 @@ 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(
116+
*,
117+
deprecated,
118+
message: "Specifying exeuction strategies and instrumentation will be removed in a future version."
119+
)
89120
public func graphql(
90121
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
91122
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -155,6 +186,35 @@ public func graphql(
155186
/// an error occurs only in a specific field. If that happens the value of that field will be `null`
156187
/// and there will be an error inside `errors` specifying the reason for the failure and the path of
157188
/// the failed field.
189+
public func graphql<Retrieval: PersistedQueryRetrieval>(
190+
queryRetrieval: Retrieval,
191+
queryId: Retrieval.Id,
192+
rootValue: Any = (),
193+
context: Any = (),
194+
eventLoopGroup: EventLoopGroup,
195+
variableValues: [String: Map] = [:],
196+
operationName: String? = nil
197+
) throws -> Future<GraphQLResult> {
198+
return try graphql(
199+
queryStrategy: ConcurrentFieldExecutionStrategy(),
200+
mutationStrategy: SerialFieldExecutionStrategy(),
201+
subscriptionStrategy: ConcurrentFieldExecutionStrategy(),
202+
instrumentation: NoOpInstrumentation,
203+
queryRetrieval: queryRetrieval,
204+
queryId: queryId,
205+
rootValue: rootValue,
206+
context: context,
207+
eventLoopGroup: eventLoopGroup,
208+
variableValues: variableValues,
209+
operationName: operationName
210+
)
211+
}
212+
213+
@available(
214+
*,
215+
deprecated,
216+
message: "Specifying exeuction strategies and instrumentation will be removed in a future version."
217+
)
158218
public func graphql<Retrieval: PersistedQueryRetrieval>(
159219
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
160220
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -229,6 +289,37 @@ public func graphql<Retrieval: PersistedQueryRetrieval>(
229289
/// that happens the value of that field will be `null` and there
230290
/// will be an error inside `errors` specifying the reason for the failure and the path of the
231291
/// failed field.
292+
public func graphqlSubscribe(
293+
schema: GraphQLSchema,
294+
request: String,
295+
rootValue: Any = (),
296+
context: Any = (),
297+
eventLoopGroup: EventLoopGroup,
298+
variableValues: [String: Map] = [:],
299+
operationName: String? = nil,
300+
validationRules: [(ValidationContext) -> Visitor] = []
301+
) throws -> Future<SubscriptionResult> {
302+
return try graphqlSubscribe(
303+
queryStrategy: ConcurrentFieldExecutionStrategy(),
304+
mutationStrategy: SerialFieldExecutionStrategy(),
305+
subscriptionStrategy: ConcurrentFieldExecutionStrategy(),
306+
instrumentation: NoOpInstrumentation,
307+
validationRules: validationRules,
308+
schema: schema,
309+
request: request,
310+
rootValue: rootValue,
311+
context: context,
312+
eventLoopGroup: eventLoopGroup,
313+
variableValues: variableValues,
314+
operationName: operationName
315+
)
316+
}
317+
318+
@available(
319+
*,
320+
deprecated,
321+
message: "Specifying exeuction strategies and instrumentation will be removed in a future version."
322+
)
232323
public func graphqlSubscribe(
233324
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
234325
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -310,6 +401,32 @@ public func graphqlSubscribe(
310401
/// field will be `null` and there will be an error inside `errors` specifying the reason for
311402
/// the failure and the path of the failed field.
312403
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
404+
public func graphql(
405+
schema: GraphQLSchema,
406+
request: String,
407+
rootValue: Any = (),
408+
context: Any = (),
409+
eventLoopGroup: EventLoopGroup,
410+
variableValues: [String: Map] = [:],
411+
operationName: String? = nil
412+
) async throws -> GraphQLResult {
413+
return try await graphql(
414+
schema: schema,
415+
request: request,
416+
rootValue: rootValue,
417+
context: context,
418+
eventLoopGroup: eventLoopGroup,
419+
variableValues: variableValues,
420+
operationName: operationName
421+
).get()
422+
}
423+
424+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
425+
@available(
426+
*,
427+
deprecated,
428+
message: "Specifying exeuction strategies and instrumentation will be removed in a future version."
429+
)
313430
public func graphql(
314431
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
315432
mutationStrategy: MutationFieldExecutionStrategy = SerialFieldExecutionStrategy(),
@@ -377,6 +494,32 @@ public func graphql(
377494
/// will be an error inside `errors` specifying the reason for the failure and the path of the
378495
/// failed field.
379496
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
497+
public func graphqlSubscribe(
498+
schema: GraphQLSchema,
499+
request: String,
500+
rootValue: Any = (),
501+
context: Any = (),
502+
eventLoopGroup: EventLoopGroup,
503+
variableValues: [String: Map] = [:],
504+
operationName: String? = nil
505+
) async throws -> SubscriptionResult {
506+
return try await graphqlSubscribe(
507+
schema: schema,
508+
request: request,
509+
rootValue: rootValue,
510+
context: context,
511+
eventLoopGroup: eventLoopGroup,
512+
variableValues: variableValues,
513+
operationName: operationName
514+
).get()
515+
}
516+
517+
@available(macOS 10.15, iOS 15, watchOS 8, tvOS 15, *)
518+
@available(
519+
*,
520+
deprecated,
521+
message: "Specifying exeuction strategies and instrumentation will be removed in a future version."
522+
)
380523
public func graphqlSubscribe(
381524
queryStrategy: QueryFieldExecutionStrategy = ConcurrentFieldExecutionStrategy(),
382525
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)