ApolloController
is the abstract base class at the heart of Apollo Elements. You should not import ApolloController
directly, instead use the subclasses: ApolloQueryController
, ApolloMutationController
, and ApolloSubscriptionController
.
Properties
called
data
Latest data for the operation, or null
.
error
Latest error from the operation, or null
.
errors
Latest errors from the operation, or []
.
loading
Whether a request is in-flight.
options
ApolloControllerOptions<D, V>
Options for the operation and controller.
Option |
Type |
Description |
client |
ApolloClient<NormalizedCacheObject> |
The ApolloClient instance for the controller. |
variables |
Variables<D, V> |
Variables for the operation. |
context |
any |
Context passed to the link execution chain. |
errorPolicy |
ErrorPolicy |
the error policy for the operation |
hostElement |
HTMLElement |
When provided, the controller will fall back to this element to fire events |
client
The ApolloClient
instance for this controller.
document
ComponentDocument<D, V> | null
The GraphQL document for the operation.
variables
Variables for the operation.
Methods
hostConnected
Returns
hostDisconnected
Returns
Events
apollo-controller-connected
ApolloControllerConnectedEvent
The controller’s host connected to the DOM.
apollo-controller-disconnected
ApolloControllerDisconnectedEvent
The controller’s host disconnected from the DOM.
Private Properties
#options
privateApolloControllerOptions<D, V>
Option |
Type |
Description |
client |
ApolloClient<NormalizedCacheObject> |
The ApolloClient instance for the controller. |
variables |
Variables<D, V> |
Variables for the operation. |
context |
any |
Context passed to the link execution chain. |
errorPolicy |
ErrorPolicy |
the error policy for the operation |
hostElement |
HTMLElement |
When provided, the controller will fall back to this element to fire events |
#client
private
#document
privateComponentDocument<D, V> | null
emitter
protectedThe event emitter to use when firing events, usually the host element.
Private Methods
notify
protectedrequests an update on the host with the provided properties.
Parameters
properties
Returns
documentChanged
protectedcallback for when the GraphQL document changes.
Parameters
document
ComponentDocument<D, V> | null
Returns
variablesChanged
protectedcallback for when the GraphQL variables change.
Parameters
variables
Returns
clientChanged
protectedcallback for when the Apollo client changes.
Parameters
client
Returns
optionsChanged
protectedcallback for when the options change.
Parameters
options
ApolloControllerOptions<D, V>
Option |
Type |
Description |
client |
ApolloClient<NormalizedCacheObject> |
The ApolloClient instance for the controller. |
variables |
Variables<D, V> |
Variables for the operation. |
context |
any |
Context passed to the link execution chain. |
errorPolicy |
ErrorPolicy |
the error policy for the operation |
hostElement |
HTMLElement |
When provided, the controller will fall back to this element to fire events |
Returns
init
protectedAssigns the controller’s variables and GraphQL document.
Parameters
document
ComponentDocument<D, V> | null
Returns
Exports
js ApolloController
from apollo-controller.js