Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

lit-apollo: ApolloSubscription

Looking for reactive Apollo controllers? See @apollo-elements/core

ApolloSubscription inherits from ApolloElement and implements the ApolloSubscriptionInterface.

Read the subscription component guides for examples and tips.

ApolloSubscription

🚀 LitElement base class that updates with an Apollo GraphQL subscription.

See ApolloSubscriptionInterface for more information on events

Properties

static

is

(read-only)
string

subscription

ComponentDocument<D> | null

A GraphQL document containing a single subscription.

skip

boolean

If true, the query will be skipped entirely

shouldResubscribe

boolean

Determines if your subscription should be unsubscribed and subscribed again.

pollInterval

number | undefined

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

notifyOnNetworkStatusChange

boolean | undefined

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

noAutoSubscribe

no-auto-subscribe
boolean

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

fetchPolicy

fetch-policy
C.FetchPolicy | undefined

Specifies the FetchPolicy to be used for this subscription.

errorPolicy

C.ErrorPolicy | undefined

Error policy for the subscription

canAutoSubscribe

(read-only)
boolean

Flags an element that's ready and able to auto subscribe

client

inherited from ApolloElement
ApolloClient<NormalizedCacheObject> | null

The Apollo Client instance.

context

inherited from ApolloElement
Record<string, unknown> | undefined

Context passed to the link execution chain.

controller

inherited from ApolloElement
ApolloController<D, V>

data

inherited from ApolloElement
Data<D> | null

Latest Data.

document

inherited from ApolloElement
ComponentDocument<D> | null

Operation document. GraphQL operation document i.e. query, subscription, or mutation. Must be a parsed GraphQL DocumentNode

error

inherited from ApolloElement
Error | ApolloError | null

Latest error

errors

inherited from ApolloElement
readonly GraphQLError[]

Latest errors

loading

inherited from ApolloElement
boolean

Whether a request is in flight.

readyToReceiveDocument

inherited from ApolloElement
boolean

variables

inherited from ApolloElement
Variables<D, V> | null

Operation variables.

Methods

subscribe

Resets the observable and subscribes.

Parameters

args

Parameters<this['controller']['subscribe']>

Returns

void

shouldSubscribe

Determines whether the element should attempt to subscribe automatically Override to prevent subscribing unless your conditions are met

Parameters

options

Partial<C.SubscriptionOptions<Variables<D, V>, Data<D>>>

Returns

boolean

onSubscriptionData

Callback for when data is updated

Parameters

result

OnSubscriptionDataParams<Data<D>>

Returns

void

onSubscriptionComplete

Callback for when subscription completes.

Returns

void

onError

Callback for when error is updated

Parameters

error

C.ApolloError

Returns

void

cancel

Cancels and clears the subscription

Returns

void

Events

Name Type Description
apollo-element-connected
ApolloElementEvent
apollo-element-disconnected
ApolloElementEvent

Exports

import { ApolloSubscription } from '@apollo-elements/lit-apollo/apollo-subscription';