Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing HelloWorldAsyncTests and Added missing initializer for SubscriptionField #79

Merged
merged 2 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Sources/Graphiti/Subscription/SubscribeField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,28 @@ public extension SubscriptionField where FieldType : Encodable {
) {
self.init(name: name, arguments: arguments(), concurrentResolve: function, concurrentSubscribe: subFunc)
}

@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *)
convenience init(
_ name: String,
as: FieldType.Type,
atSub subFunc: @escaping ConcurrentResolve<ObjectType, Context, Arguments, EventStream<SourceEventType>>,
@ArgumentComponentBuilder<Arguments> _ arguments: () -> ArgumentComponent<Arguments>
) {

self.init(name: name, arguments: [arguments()], as: `as`, concurrentSubscribe: subFunc)
}

@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *)
convenience init(
_ name: String,
as: FieldType.Type,
atSub subFunc: @escaping ConcurrentResolve<ObjectType, Context, Arguments, EventStream<SourceEventType>>,
@ArgumentComponentBuilder<Arguments> _ arguments: () -> [ArgumentComponent<Arguments>] = {[]}
) {

self.init(name: name, arguments: arguments(), as: `as`, concurrentSubscribe: subFunc)
}
}

public extension SubscriptionField {
Expand All @@ -455,6 +477,7 @@ public extension SubscriptionField {
) {
self.init(name: name, arguments: arguments(), concurrentResolve: function, concurrentSubscribe: subFunc)
}

}

#endif
Expand Down
10 changes: 6 additions & 4 deletions Tests/GraphitiTests/HelloWorldTests/HelloWorldAsyncTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ extension HelloResolver {
@available(macOS 12, iOS 15, watchOS 8, tvOS 15, *)
// Same as the HelloAPI, except with an async query and a few subscription fields
struct HelloAsyncAPI : API {
let resolver = HelloResolver()
let context = HelloContext()
typealias ContextType = HelloContext

let resolver: HelloResolver = HelloResolver()
let context: HelloContext = HelloContext()

let schema = try! Schema<HelloResolver, HelloContext> {
let schema: Schema<HelloResolver, HelloContext> = try! Schema<HelloResolver, HelloContext> {
Scalar(Float.self)
.description("The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point).")

Expand Down Expand Up @@ -91,7 +93,7 @@ struct HelloAsyncAPI : API {
SubscriptionField("subscribeUserEvent", at: User.toEvent, atSub: HelloResolver.subscribeUser)

SubscriptionField("futureSubscribeUser", as: User.self, atSub: HelloResolver.subscribeUser)
SubscriptionField("asyncSubscribeUser", as: User.self, atSub: HelloResolver.subscribeUser)
SubscriptionField("asyncSubscribeUser", as: User.self, atSub: HelloResolver.asyncSubscribeUser)
NeedleInAJayStack marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Expand Down