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

Class Mixins: ApolloMutationMixin

ApolloMutationMixins applies ApolloElementMixin and the ApolloMutationInterface.

Read the mutation component guides for examples and tips.

Attributes

refetch-queries


await-refetch-queries


fetch-policy

inherited from ApolloElementMixin

Signature

ApolloMutationMixin

Parameters

base

B

Properties

static

documentType

inherited from ApolloElementMixin
'document'|'query'|'mutation'|'subscription'

refetchQueries

RefetchQueriesType<D> | null

optimisticResponse

OptimisticResponseType<D, V> | undefined

An object that represents the result of this mutation that will be optimistically stored before the server has actually returned a result, or a unary function that takes the mutation's variables and returns such an object.

This is most often used for optimistic UI, where we want to be able to see the result of a mutation immediately, and update the UI later if any errors appear.

mutation

ComponentDocument<D, V> | null

ignoreResults

boolean

called

boolean

awaitRefetchQueries

boolean | undefined

client

inherited from ApolloElementMixin
ApolloClient<NormalizedCacheObject> | null

The Apollo Client instance.

context

inherited from ApolloElementMixin
Record<string, unknown> | undefined

Context passed to the link execution chain.

controller

inherited from ApolloElementMixin
ApolloController<D, V>

data

inherited from ApolloElementMixin
Data<D> | null

Latest data

document

inherited from ApolloElementMixin
ComponentDocument<D, V> | null

Operation document. A GraphQL document containing a single query, mutation, or subscription. You can set it as a JavaScript property or by appending a GraphQL script to the element (light DOM).

error

inherited from ApolloElementMixin
Error | ApolloError | null

Latest error.

errorPolicy

inherited from ApolloElementMixin error-policy
ErrorPolicy | undefined

Error Policy for the operation.

errorPolicy determines the level of events for errors in the execution result. The options are:

  • none (default): any errors from the request are treated like runtime errors and the observable is stopped (XXX this is default to lower breaking changes going from AC 1.0 => 2.0)
  • ignore: errors from the request do not stop the observable, but also don't call next
  • all: errors are treated like data and will notify observables

errors

inherited from ApolloElementMixin
readonly GraphQLError[]

Latest errors.

fetchPolicy

inherited from ApolloElementMixin
string | undefined

Fetch Policy for the operation.

loading

inherited from ApolloElementMixin
boolean

Whether a request is in-flight.

public

readyToReceiveDocument

inherited from ApolloElementMixin
boolean

True when the element is connected and ready to receive its GraphQL document

updateComplete

inherited from ControllerHostMixin
Promise<boolean>

variables

inherited from ApolloElementMixin
Variables<D, V> | null

Operation variables. An object that maps from the name of a variable as used in the operation's GraphQL document to that variable's value.

Methods

updater

Parameters

params

Parameters<MutationUpdaterFn<Data<D>, Variables<D, V>>>

Returns

ReturnType<MutationUpdaterFn<Data<D>, Variables<D, V>>>

onError

Parameters

_error

Error

Returns

void

onCompleted

Parameters

_data

Data<D>

Returns

void
public

mutate

This resolves a single mutation according to the options specified and returns a Promise which is either resolved with the resulting data or rejected with an error.

Parameters

params

Partial<C.MutationOptions<Data<D>, Variables<D, V>>>

Returns

Promise<C.FetchResult<Data<D>>>

addController

inherited from ControllerHostMixin

Parameters

controller

ReactiveController

Returns

void

removeController

inherited from ControllerHostMixin

Parameters

controller

ReactiveController

Returns

void

requestUpdate

inherited from ControllerHostMixin

Returns

void

update

inherited from ControllerHostMixin

Parameters

args

any[]

updated

inherited from ControllerHostMixin

Parameters

args

any[]

Events

Name Type Description
apollo-element-connected
ApolloElementEvent
apollo-element-disconnected
ApolloElementEvent
Private API

Private Properties

private

#controllers

inherited from ControllerHostMixin

private

#resolve

inherited from ControllerHostMixin
(v: boolean) => void
private

#updateComplete

inherited from ControllerHostMixin

private

#updatePending

inherited from ControllerHostMixin
boolean

Private Methods

protected

documentChanged

inherited from ApolloElementMixin

Lifecycle callback that reacts to changes in the GraphQL document.

Parameters

document

this['document']

The GraphQL document.

Returns

void
private

doUpdate

inherited from ControllerHostMixin
protected

variablesChanged

inherited from ApolloElementMixin

Lifecycle callback that reacts to changes in the operation variables.

Parameters

variables

this['variables']

The variables.

Returns

void

Exports

import { ApolloMutationMixin } from '@apollo-elements/mixins/apollo-mutation-mixin';