@@ -357,6 +357,109 @@ public extension SubscriptionField {
357
357
}
358
358
}
359
359
360
+ #if compiler(>=5.5) && canImport(_Concurrency)
361
+
362
+ public extension SubscriptionField {
363
+
364
+ @available ( macOS 12 , iOS 15 , watchOS 8 , tvOS 15 , * )
365
+ convenience init < ResolveType> (
366
+ name: String ,
367
+ arguments: [ ArgumentComponent < Arguments > ] ,
368
+ concurrentResolve: @escaping ConcurrentResolve < SourceEventType , Context , Arguments , ResolveType > ,
369
+ concurrentSubscribe: @escaping ConcurrentResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > >
370
+ ) {
371
+ let asyncResolve : AsyncResolve < SourceEventType , Context , Arguments , ResolveType > = { type in
372
+ { context, arguments, eventLoopGroup in
373
+ let promise = eventLoopGroup. next ( ) . makePromise ( of: ResolveType . self)
374
+ promise. completeWithTask {
375
+ try await concurrentResolve ( type) ( context, arguments)
376
+ }
377
+ return promise. futureResult
378
+ }
379
+ }
380
+ let asyncSubscribe : AsyncResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > > = { type in
381
+ { context, arguments, eventLoopGroup in
382
+ let promise = eventLoopGroup. next ( ) . makePromise ( of: EventStream< SourceEventType> . self )
383
+ promise. completeWithTask {
384
+ try await concurrentSubscribe ( type) ( context, arguments)
385
+ }
386
+ return promise. futureResult
387
+ }
388
+ }
389
+ self . init ( name: name, arguments: arguments, asyncResolve: asyncResolve, asyncSubscribe: asyncSubscribe)
390
+ }
391
+
392
+ @available ( macOS 12 , iOS 15 , watchOS 8 , tvOS 15 , * )
393
+ convenience init (
394
+ name: String ,
395
+ arguments: [ ArgumentComponent < Arguments > ] ,
396
+ as: FieldType . Type ,
397
+ concurrentSubscribe: @escaping ConcurrentResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > >
398
+ ) {
399
+ let asyncSubscribe : AsyncResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > > = { type in
400
+ { context, arguments, eventLoopGroup in
401
+ let promise = eventLoopGroup. next ( ) . makePromise ( of: EventStream< SourceEventType> . self )
402
+ promise. completeWithTask {
403
+ try await concurrentSubscribe ( type) ( context, arguments)
404
+ }
405
+ return promise. futureResult
406
+ }
407
+ }
408
+ self . init ( name: name, arguments: arguments, as: `as`, asyncSubscribe: asyncSubscribe)
409
+ }
410
+ }
411
+
412
+ // MARK: ConcurrentResolve Initializers
413
+
414
+ public extension SubscriptionField where FieldType : Encodable {
415
+ @available ( macOS 12 , iOS 15 , watchOS 8 , tvOS 15 , * )
416
+ convenience init (
417
+ _ name: String ,
418
+ at function: @escaping ConcurrentResolve < SourceEventType , Context , Arguments , FieldType > ,
419
+ atSub subFunc: @escaping ConcurrentResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > > ,
420
+ @ArgumentComponentBuilder < Arguments > _ argument: ( ) -> ArgumentComponent < Arguments >
421
+ ) {
422
+ self . init ( name: name, arguments: [ argument ( ) ] , concurrentResolve: function, concurrentSubscribe: subFunc)
423
+ }
424
+
425
+ @available ( macOS 12 , iOS 15 , watchOS 8 , tvOS 15 , * )
426
+ convenience init (
427
+ _ name: String ,
428
+ at function: @escaping ConcurrentResolve < SourceEventType , Context , Arguments , FieldType > ,
429
+ atSub subFunc: @escaping ConcurrentResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > > ,
430
+ @ArgumentComponentBuilder < Arguments > _ arguments: ( ) -> [ ArgumentComponent < Arguments > ] = { [ ] }
431
+ ) {
432
+ self . init ( name: name, arguments: arguments ( ) , concurrentResolve: function, concurrentSubscribe: subFunc)
433
+ }
434
+ }
435
+
436
+ public extension SubscriptionField {
437
+ @available ( macOS 12 , iOS 15 , watchOS 8 , tvOS 15 , * )
438
+ convenience init < ResolveType> (
439
+ _ name: String ,
440
+ at function: @escaping ConcurrentResolve < SourceEventType , Context , Arguments , ResolveType > ,
441
+ as: FieldType . Type ,
442
+ atSub subFunc: @escaping ConcurrentResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > > ,
443
+ @ArgumentComponentBuilder < Arguments > _ argument: ( ) -> ArgumentComponent < Arguments >
444
+ ) {
445
+ self . init ( name: name, arguments: [ argument ( ) ] , concurrentResolve: function, concurrentSubscribe: subFunc)
446
+ }
447
+
448
+ @available ( macOS 12 , iOS 15 , watchOS 8 , tvOS 15 , * )
449
+ convenience init < ResolveType> (
450
+ _ name: String ,
451
+ at function: @escaping ConcurrentResolve < SourceEventType , Context , Arguments , ResolveType > ,
452
+ as: FieldType . Type ,
453
+ atSub subFunc: @escaping ConcurrentResolve < ObjectType , Context , Arguments , EventStream < SourceEventType > > ,
454
+ @ArgumentComponentBuilder < Arguments > _ arguments: ( ) -> [ ArgumentComponent < Arguments > ] = { [ ] }
455
+ ) {
456
+ self . init ( name: name, arguments: arguments ( ) , concurrentResolve: function, concurrentSubscribe: subFunc)
457
+ }
458
+ }
459
+
460
+ #endif
461
+
462
+
360
463
// TODO Determine if we can use keypaths to initialize
361
464
362
465
// MARK: Keypath Initializers
0 commit comments