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
(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-subscribeboolean
If true, the element will not begin querying data until you manually call subscribe
fetchPolicy
fetch-policyC.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 ApolloElementApolloClient<NormalizedCacheObject> | null
The Apollo Client instance.
context
inherited from ApolloElementRecord<string, unknown> | undefined
Context passed to the link execution chain.
controller
inherited from ApolloElementApolloController<D, V>
data
inherited from ApolloElementData<D> | null
Latest Data.
document
inherited from ApolloElementComponentDocument<D> | null
Operation document.
GraphQL operation document i.e. query, subscription, or mutation.
Must be a parsed GraphQL DocumentNode
error
inherited from ApolloElementError | ApolloError | null
Latest error
errors
inherited from ApolloElementreadonly GraphQLError[]
Latest errors
loading
inherited from ApolloElementboolean
Whether a request is in flight.
readyToReceiveDocument
inherited from ApolloElementboolean
variables
inherited from ApolloElementVariables<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 |
|
|
apollo-element-disconnected |
|
Exports
import { ApolloSubscription } from '@apollo-elements/lit-apollo/apollo-subscription';