Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ApolloSubscriptionInterface<TData, TVariables>

Type parameters

  • TData

  • TVariables

Hierarchy

Implemented by

Index

Properties

client

The Apollo Client instance.

Optional context

context: Record<string, unknown>

Context to be passed to link execution chain.

data

data: TData

Latest data

document

document: DocumentNode

GraphQL operation document i.e. query, subscription, or mutation. Must be a parsed GraphQL DocumentNode, so use graphql-tag. If unset, the element can derive the document from the first light-DOM <script type="application/graphql"> child.

error

Latest error

errors

errors: readonly GraphQLError[]

Latest errors

Optional fetchPolicy

fetchPolicy: FetchPolicy

Specifies the FetchPolicy to be used for this subscription.

loading

loading: boolean

Whether a request is in flight.

Optional noAutoSubscribe

noAutoSubscribe: boolean

If true, the element will not begin querying data until you manually call subscribe

Optional notifyOnNetworkStatusChange

notifyOnNetworkStatusChange: boolean

Whether or not updates to the network status should trigger next on the observer of this subscription.

observable

observable: Observable<FetchResult<TData>>

Observable watching this element's subscription.

observableSubscription

observableSubscription: Subscription

Subscription to the observable

Optional pollInterval

pollInterval: number

The time interval (in milliseconds) on which this subscription should be refetched from the server.

skip

skip: boolean

If skip is true, the query will be skipped entirely

subscription

subscription: DocumentNode

A GraphQL document containing a single subscription.

Optional variables

variables: TVariables

An object map from variable name to variable value, where the variables are used within the GraphQL subscription.

Methods

Protected canSubscribe

  • canSubscribe(options?: Partial<SubscriptionOptions>): boolean
  • Determines whether the element is able to automatically subscribe

    Parameters

    • Optional options: Partial<SubscriptionOptions>

    Returns boolean

cancel

  • cancel(): void
  • Cancels and clears the subscription

    Returns void

Private endSubscription

  • endSubscription(): void
  • Returns void

Private initObservable

  • Parameters

    Returns void

Private nextData

  • nextData(result: FetchResult<TData>): void
  • Sets data, loading, and error on the instance when new subscription results arrive.

    Parameters

    • result: FetchResult<TData>

    Returns void

Private nextError

  • Sets error and loading on the instance when the subscription errors.

    Parameters

    Returns void

Private onComplete

  • onComplete(): void
  • Shuts down the subscription

    Returns void

Optional onSubscriptionComplete

  • onSubscriptionComplete(): void
  • Callback for when subscription completes.

    Returns void

Optional onSubscriptionData

  • Callback for when data is updated

    Parameters

    Returns void

shouldSubscribe

  • shouldSubscribe(options?: Partial<SubscriptionOptions>): boolean
  • Determines whether the element should attempt to subscribe i.e. begin querying Override to prevent subscribing unless your conditions are met

    Parameters

    • Optional options: Partial<SubscriptionOptions>

    Returns boolean

subscribe

  • Resets the observable and subscribes.

    Parameters

    Returns void