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
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 ApolloElementMixinApolloClient<NormalizedCacheObject> | null
The Apollo Client instance.
context
inherited from ApolloElementMixinRecord<string, unknown> | undefined
Context passed to the link execution chain.
controller
inherited from ApolloElementMixinApolloController<D, V>
data
inherited from ApolloElementMixinData<D> | null
Latest data
document
inherited from ApolloElementMixinComponentDocument<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 ApolloElementMixinError | ApolloError | null
Latest error.
errorPolicy
inherited from ApolloElementMixin error-policyErrorPolicy | 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 callnext
all
: errors are treated like data and will notify observables
errors
inherited from ApolloElementMixinreadonly GraphQLError[]
Latest errors.
fetchPolicy
inherited from ApolloElementMixinstring | undefined
Fetch Policy for the operation.
loading
inherited from ApolloElementMixinboolean
Whether a request is in-flight.
readyToReceiveDocument
inherited from ApolloElementMixinboolean
True when the element is connected and ready to receive its GraphQL document
updateComplete
inherited from ControllerHostMixinPromise<boolean>
variables
inherited from ApolloElementMixinVariables<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
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 ControllerHostMixinParameters
controller
ReactiveController
Returns
void
removeController
inherited from ControllerHostMixinParameters
controller
ReactiveController
Returns
void
requestUpdate
inherited from ControllerHostMixinReturns
void
update
inherited from ControllerHostMixinParameters
args
any[]
updated
inherited from ControllerHostMixinParameters
args
any[]
Events
Name | Type | Description |
---|---|---|
apollo-element-connected |
|
|
apollo-element-disconnected |
|
Private API
Private Properties
#controllers
inherited from ControllerHostMixin
#resolve
inherited from ControllerHostMixin(v: boolean) => void
#updateComplete
inherited from ControllerHostMixin
#updatePending
inherited from ControllerHostMixinboolean
Private Methods
documentChanged
inherited from ApolloElementMixinLifecycle callback that reacts to changes in the GraphQL document.
Parameters
document
this['document']
The GraphQL document.
Returns
void
doUpdate
inherited from ControllerHostMixinvariablesChanged
inherited from ApolloElementMixinLifecycle 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';