<link rel="stylesheet" href="/_merged_assets/_static/search/noscript.css">
Apollo Elements Apollo Elements Guides API Blog Toggle darkmode

Controllers: ApolloController

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

variables

Variables<D, V> | null

Variables for the operation.

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

loading

boolean

Whether a request is in-flight.

errors

readonly GraphQLError[]

Latest errors from the operation, or [].

error

ApolloError | null

Latest error from the operation, or null.

document

ComponentDocument<D, V> | null

The GraphQL document for the operation.

data

Data<D> | null

Latest data for the operation, or null.

client

ApolloClient<NormalizedCacheObject> | null

The ApolloClient instance for this controller.

called

boolean

Methods

hostDisconnected

Returns

void

hostConnected

Returns

void

Events

Name Type Description
apollo-controller-disconnected
ApolloControllerDisconnectedEvent

The controller's host disconnected from the DOM.

apollo-controller-connected
ApolloControllerConnectedEvent

The controller's host connected to the DOM.

Private API

Private Properties

protected

emitter

EventTarget

The event emitter to use when firing events, usually the host element.

private

#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
private

#document

ComponentDocument<D, V> | null
private

#client

ApolloClient<NormalizedCacheObject> | null

Private Methods

protected

variablesChanged

callback for when the GraphQL variables change.

Parameters

variables

Variables<D, V> | null

Returns

void
protected

optionsChanged

callback 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

void
protected

notify

requests an update on the host with the provided properties.

Parameters

properties

Record<string, unknown>

Returns

void
protected

init

Assigns the controller's variables and GraphQL document.

Parameters

document

ComponentDocument<D, V> | null

Returns

void
protected

documentChanged

callback for when the GraphQL document changes.

Parameters

document

ComponentDocument<D, V> | null

Returns

void
protected

clientChanged

callback for when the Apollo client changes.

Parameters

client

ApolloClient<NormalizedCacheObject> | null

Returns

void

Exports

import { ApolloController } from '@apollo-elements/core/apollo-controller';