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

is

static(read-only)
string

controller

ApolloController<D, V>

canAutoSubscribe

(read-only)
boolean
Flags an element that’s ready and able to auto subscribe

subscription

ComponentDocument<D, V> | null
A GraphQL document containing a single subscription.

noAutoSubscribe

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

notifyOnNetworkStatusChange

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

shouldResubscribe

boolean
Determines if your subscription should be unsubscribed and subscribed again.

skip

boolean
If true, the query will be skipped entirely

errorPolicy

C.ErrorPolicy | undefined
Error policy for the subscription

fetchPolicy

C.FetchPolicy | undefined
Specifies the FetchPolicy to be used for this subscription.

pollInterval

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

readyToReceiveDocument

boolean

client

ApolloClient<NormalizedCacheObject> | null
The Apollo Client instance.

document

ComponentDocument<D, V> | null
Operation document. GraphQL operation document i.e. query, subscription, or mutation. Must be a parsed GraphQL DocumentNode

context

Record<string, unknown> | undefined
Context passed to the link execution chain.

loading

boolean
Whether a request is in flight.

data

Data<D> | null
Latest Data.

variables

Variables<D, V> | null
Operation variables.

error

Error | ApolloError | null
Latest error

errors

readonly GraphQLError[]
Latest errors

Methods

subscribe

Resets the observable and subscribes.

Parameters

args

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

Returns

void

cancel

Cancels and clears the subscription

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

onError

Callback for when error is updated

Parameters

error

C.ApolloError

Returns

void

onSubscriptionComplete

Callback for when subscription completes.

Returns

void

Events

apollo-element-connected

ApolloElementEvent

apollo-element-disconnected

ApolloElementEvent

Exports

js ApolloSubscription from apollo-subscription.js