GraphQLSubscriptionOperation

open class GraphQLSubscriptionOperation<R: Decodable>: AmplifyInProcessReportingOperation<
    GraphQLOperationRequest<R>,
    GraphQLSubscriptionEvent<R>,
    Void,
    APIError
>
extension GraphQLSubscriptionOperation: AnyGraphQLOperation

GraphQL Subscription Operation

GraphQLSubscriptionOperation

  • Publishes the state of the GraphQL subscription’s underlying network connection.

    Subscription termination will be reported as a completion on the subscriptionDataPublisher completion, so this is really only useful if you want to monitor the .connected state.

    Declaration

    Swift

    var connectionStatePublisher: AnyPublisher<SubscriptionConnectionState, APIError> { get }
  • Publishes the data received from a GraphQL subscription.

    The publisher emits GraphQLResponse events, which are standard Swift Result values that contain either a successfully decoded response value, or a GraphQLResponseError describing the reason that a value could not be successfully decoded. Receiving a .failure response does not mean the subscription is terminated–the subscription may still receive values, and each value is independently evaluated. Thus, you may see a data stream containing a mix of successfully decoded responses, partially decoded responses, or decoding errors, none of which affect the state of the underlying subscription connection.

    When the subscription terminates with a cancellation or disconnection, this publisher will receive a completion.

    Declaration

    Swift

    var subscriptionDataPublisher: AnyPublisher<GraphQLResponse<R>, Failure> { get }