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.

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> | 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
Private API

Private Properties

protected

emitter

EventTarget

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

private

#options

ApolloControllerOptions<D, V>
private

#document

ComponentDocument<D> | 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

notify

Notifies about updated properties.

Parameters

keys

(keyof this)[]

Returns

void
protected

init

Assigns the controller's variables and GraphQL document.

Parameters

document

ComponentDocument<D> | null

Returns

void
protected

documentChanged

callback for when the GraphQL document changes.

Parameters

document

ComponentDocument<D> | null

Returns

void
protected

clientChanged

callback for when the Apollo client changes.

Parameters

client

ApolloClient<NormalizedCacheObject> | null

Returns

void
private

[update]

requests an update on the host.

Parameters

properties

Record<string, unknown>

Returns

void

Exports

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