Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ApolloSubscription<TData, TVariables>

ApolloSubscription

🚀 Custom element base class that updates with an Apollo GraphQL subscription.

element

See ApolloSubscriptionInterface for more information on events

Type parameters

  • TData

  • TVariables

Hierarchy

Implements

Index

Properties

Private _document

_document: DocumentNode | null = null

Private _documentSetByJS

_documentSetByJS: boolean = false

Private _variables

_variables: TVariables | null = null

Private _variablesSetByJS

_variablesSetByJS: boolean = false

client

client: ApolloClient<NormalizedCacheObject> | null = window.__APOLLO_CLIENT__ ?? null

Optional context

context: Record<string, unknown>

data

data: TData | null

error

error: Error | ApolloError | null

errors

errors: readonly GraphQLError[] | null

Optional fetchPolicy

fetchPolicy: FetchPolicy

loading

loading: boolean

Private mo

mo: MutationObserver | null = null

noAutoSubscribe

noAutoSubscribe: boolean

notifyOnNetworkStatusChange

notifyOnNetworkStatusChange: boolean = false

Optional observable

observable: Observable<FetchResult<TData>>

Optional observableSubscription

observableSubscription: ZenObservable.Subscription

Optional pollInterval

pollInterval: undefined | number

shouldResubscribe

shouldResubscribe: SubscriptionDataOptions["shouldResubscribe"] = false

skip

skip: boolean = false

subscription

subscription: DocumentNode | null

variables

variables: TVariables | null

Static documentType

documentType: string = "subscription"

Accessors

document

Methods

Optional adoptedCallback

  • adoptedCallback(): void

Optional attributeChangedCallback

  • attributeChangedCallback(name: string, oldValue: string, newValue: string): void
  • Called when one of the element's observedAttributes changes.

    Parameters

    • name: string

      name of the observed attribute

    • oldValue: string

      previous value of the attribute. null if it was nonexistent

    • newValue: string

      current value of the attribute. null if removed.

    Returns void

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

Protected connectedCallback

  • connectedCallback(): void

Protected disconnectedCallback

  • disconnectedCallback(): void

documentChanged

Private endSubscription

  • endSubscription(): void

Private getDOMGraphQLDocument

Private getDOMVariables

  • getDOMVariables(): TVariables | null

Private initObservable

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

Private onComplete

  • onComplete(): void

Private onDOMMutation

  • onDOMMutation(records: MutationRecord[]): void

Optional onError

Optional onSubscriptionComplete

  • onSubscriptionComplete(): void

Optional onSubscriptionData

shouldSubscribe

  • shouldSubscribe(options?: Partial<SubscriptionOptions>): boolean
  • Determines whether the element should attempt to automatically subscribe i.e. begin querying

    Override to prevent subscribing unless your conditions are met.

    Parameters

    • Optional options: Partial<SubscriptionOptions>

    Returns boolean

subscribe

variablesChanged

  • variablesChanged(variables: TVariables): void