Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ApolloSubscription<TData, TVariables>

ApolloSubscription

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

Type parameters

  • TData

  • TVariables

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private __data

__data: TData = null

Private __document

__document: DocumentNode = null

Private __error

__error: Error | ApolloError = null

Private __errors

__errors: readonly GraphQLError[] = null

Private __loading

__loading: boolean = false

Private __mo

Private __variables

__variables: TVariables = null

client

client: ApolloClient<NormalizedCacheObject> = window.__APOLLO_CLIENT__

Optional context

context: Record<string, unknown>

data

data: TData

error

errors

errors: readonly GraphQLError[]

fetchPolicy

fetchPolicy: FetchPolicy

fetchResults

fetchResults: boolean

loading

loading: boolean

noAutoSubscribe

noAutoSubscribe: boolean

notifyOnNetworkStatusChange

notifyOnNetworkStatusChange: boolean = false

observable

observable: Observable<FetchResult<TData>>

observableSubscription

observableSubscription: Subscription

pollInterval

pollInterval: number

skip

skip: boolean

subscription

subscription: DocumentNode

variables

variables: TVariables

Static Readonly is

is: string

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

createRenderRoot

  • createRenderRoot(): ReturnType<HTMLElement["attachShadow"]> | Node

Protected disconnectedCallback

  • disconnectedCallback(): void

Private endSubscription

  • endSubscription(): void

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

  • 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 onError

Optional onSubscriptionComplete

  • onSubscriptionComplete(): void

Optional onSubscriptionData

render

  • render(options?: { sync: boolean }): Promise<void>
  • Parameters

    • Optional options: { sync: boolean }
      • sync: boolean

    Returns Promise<void>

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