Skip to content

Commit e680079

Browse files
fix: Fixes ambiguous functions
1 parent 7729118 commit e680079

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Sources/Graphiti/Field/Field/Field.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ public extension Field {
196196

197197
// MARK: SyncResolve Initializers
198198

199+
// '@_disfavoredOverload' is included below because otherwise `SimpleAsyncResolve` initializers also match this signature, causing the
200+
// calls to be ambiguous. We prefer that if an EventLoopFuture is returned from the resolve, that `SimpleAsyncResolve` is matched.
201+
199202
public extension Field {
203+
@_disfavoredOverload
200204
convenience init(
201205
_ name: String,
202206
at function: @escaping SyncResolve<ObjectType, Context, Arguments, FieldType>,
@@ -205,6 +209,7 @@ public extension Field {
205209
self.init(name: name, arguments: [argument()], syncResolve: function)
206210
}
207211

212+
@_disfavoredOverload
208213
convenience init(
209214
_ name: String,
210215
at function: @escaping SyncResolve<ObjectType, Context, Arguments, FieldType>,
@@ -216,6 +221,7 @@ public extension Field {
216221
}
217222

218223
public extension Field {
224+
@_disfavoredOverload
219225
convenience init<ResolveType>(
220226
_ name: String,
221227
at function: @escaping SyncResolve<ObjectType, Context, Arguments, ResolveType>,
@@ -225,6 +231,7 @@ public extension Field {
225231
self.init(name: name, arguments: [argument()], syncResolve: function)
226232
}
227233

234+
@_disfavoredOverload
228235
convenience init<ResolveType>(
229236
_ name: String,
230237
at function: @escaping SyncResolve<ObjectType, Context, Arguments, ResolveType>,

Sources/Graphiti/Subscription/SubscribeField.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,11 @@ public extension SubscriptionField {
491491

492492
// MARK: SyncResolve Initializers
493493

494+
// '@_disfavoredOverload' is included below because otherwise `SimpleAsyncResolve` initializers also match this signature, causing the
495+
// calls to be ambiguous. We prefer that if an EventLoopFuture is returned from the resolve, that `SimpleAsyncResolve` is matched.
496+
494497
public extension SubscriptionField {
498+
@_disfavoredOverload
495499
convenience init(
496500
_ name: String,
497501
at function: @escaping SyncResolve<SourceEventType, Context, Arguments, FieldType>,
@@ -511,6 +515,7 @@ public extension SubscriptionField {
511515
)
512516
}
513517

518+
@_disfavoredOverload
514519
convenience init(
515520
_ name: String,
516521
at function: @escaping SyncResolve<SourceEventType, Context, Arguments, FieldType>,
@@ -528,6 +533,7 @@ public extension SubscriptionField {
528533
}
529534

530535
public extension SubscriptionField {
536+
@_disfavoredOverload
531537
convenience init(
532538
_ name: String,
533539
as: FieldType.Type,
@@ -542,6 +548,7 @@ public extension SubscriptionField {
542548
self.init(name: name, arguments: [argument()], as: `as`, syncSubscribe: subFunc)
543549
}
544550

551+
@_disfavoredOverload
545552
convenience init(
546553
_ name: String,
547554
as: FieldType.Type,
@@ -557,6 +564,7 @@ public extension SubscriptionField {
557564
self.init(name: name, arguments: arguments(), as: `as`, syncSubscribe: subFunc)
558565
}
559566

567+
@_disfavoredOverload
560568
convenience init<ResolveType>(
561569
_ name: String,
562570
at function: @escaping SyncResolve<SourceEventType, Context, Arguments, ResolveType>,
@@ -577,6 +585,7 @@ public extension SubscriptionField {
577585
)
578586
}
579587

588+
@_disfavoredOverload
580589
convenience init<ResolveType>(
581590
_ name: String,
582591
at function: @escaping SyncResolve<SourceEventType, Context, Arguments, ResolveType>,

0 commit comments

Comments
 (0)