Skip to content

Commit 471791d

Browse files
author
Jay Herron
committed
Updates documentation to reflect implementation
1 parent 83632df commit 471791d

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

Sources/GraphQL/Subscription/Subscribe.swift

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,20 @@ import NIO
66
/**
77
* Implements the "Subscribe" algorithm described in the GraphQL specification.
88
*
9-
* Returns a Promise which resolves to either an AsyncIterator (if successful)
10-
* or an ExecutionResult (error). The promise will be rejected if the schema or
11-
* other arguments to this function are invalid, or if the resolved event stream
12-
* is not an async iterable.
9+
* Returns a future which resolves to a SubscriptionResult containing either
10+
* a SubscriptionObservable (if successful), or GraphQLErrors (error).
1311
*
1412
* If the client-provided arguments to this function do not result in a
15-
* compliant subscription, a GraphQL Response (ExecutionResult) with
16-
* descriptive errors and no data will be returned.
13+
* compliant subscription, the future will resolve to a
14+
* SubscriptionResult containing `errors` and no `observable`.
1715
*
1816
* If the source stream could not be created due to faulty subscription
19-
* resolver logic or underlying systems, the promise will resolve to a single
20-
* ExecutionResult containing `errors` and no `data`.
17+
* resolver logic or underlying systems, the future will resolve to a
18+
* SubscriptionResult containing `errors` and no `observable`.
2119
*
22-
* If the operation succeeded, the promise resolves to an AsyncIterator, which
23-
* yields a stream of ExecutionResults representing the response stream.
20+
* If the operation succeeded, the future will resolve to a SubscriptionResult,
21+
* containing an `observable` which yields a stream of GraphQLResults
22+
* representing the response stream.
2423
*
2524
* Accepts either an object with named arguments, or individual arguments.
2625
*/
@@ -77,7 +76,7 @@ func subscribe(
7776
operationName: operationName
7877
)
7978
}
80-
return SubscriptionResult(observable: subscriptionObservable)
79+
return SubscriptionResult(observable: subscriptionObservable, errors: sourceResult.errors)
8180
} else {
8281
return SubscriptionResult(errors: sourceResult.errors)
8382
}
@@ -88,21 +87,20 @@ func subscribe(
8887
* Implements the "CreateSourceEventStream" algorithm described in the
8988
* GraphQL specification, resolving the subscription source event stream.
9089
*
91-
* Returns a Promise which resolves to either an AsyncIterable (if successful)
92-
* or an ExecutionResult (error). The promise will be rejected if the schema or
93-
* other arguments to this function are invalid, or if the resolved event stream
94-
* is not an async iterable.
90+
* Returns a Future which resolves to a SourceEventStreamResult, containing
91+
* either an Observable (if successful) or GraphQLErrors (error).
9592
*
9693
* If the client-provided arguments to this function do not result in a
97-
* compliant subscription, a GraphQL Response (ExecutionResult) with
98-
* descriptive errors and no data will be returned.
94+
* compliant subscription, the future will resolve to a
95+
* SourceEventStreamResult containing `errors` and no `observable`.
9996
*
100-
* If the the source stream could not be created due to faulty subscription
101-
* resolver logic or underlying systems, the promise will resolve to a single
102-
* ExecutionResult containing `errors` and no `data`.
97+
* If the source stream could not be created due to faulty subscription
98+
* resolver logic or underlying systems, the future will resolve to a
99+
* SourceEventStreamResult containing `errors` and no `observable`.
103100
*
104-
* If the operation succeeded, the promise resolves to the AsyncIterable for the
105-
* event stream returned by the resolver.
101+
* If the operation succeeded, the future will resolve to a SubscriptionResult,
102+
* containing an `observable` which yields a stream of event objects
103+
* returned by the subscription resolver.
106104
*
107105
* A Source Event Stream represents a sequence of events, each of which triggers
108106
* a GraphQL execution for that event.

0 commit comments

Comments
 (0)