Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ApolloMutationElement<D, V>

Type parameters

  • D

  • V

Hierarchy

  • ApolloMutationElement<D, V>
    • ApolloMutationElement

Implements

Index

Constructors

constructor

Properties

Private _document

_document: DocumentNode | null = null

Private _documentSetByJS

_documentSetByJS: boolean = false

Private _variables

_variables: V | null = null

Private _variablesSetByJS

_variablesSetByJS: boolean = false

Optional awaitRefetchQueries

awaitRefetchQueries: undefined | false | true

called

called: boolean

client

client: ApolloClient<NormalizedCacheObject> | null = window.__APOLLO_CLIENT__ ?? null

Optional context

context: Record<string, unknown>

data

data: D | null

error

error: Error | ApolloError | null

Optional errorPolicy

errorPolicy: ErrorPolicy

errors

errors: readonly GraphQLError[] | null

Optional fetchPolicy

fetchPolicy: Extract<FetchPolicy, "no-cache">

ignoreResults

ignoreResults: boolean = false

loading

loading: boolean

Private mo

mo: MutationObserver | null = null

mostRecentMutationId

mostRecentMutationId: number = 0

mutation

mutation: DocumentNode | null

Optional optimisticResponse

optimisticResponse: D | ((vars: V) => D)

refetchQueries

refetchQueries: null | MutationOptions<D, V>["refetchQueries"]

variables

variables: V | null

Static documentType

documentType: string = "mutation"

Accessors

document

Methods

Optional adoptedCallback

  • adoptedCallback(): void
  • Called when the element is adopted to a document.

    Returns void

Optional attributeChangedCallback

  • attributeChangedCallback(name: string, oldValue: string, newValue: string): void
  • Called when one of the element's observedAttributes changes.

    Parameters

    • name: string

      name of the observed attribute

    • oldValue: string

      previous value of the attribute. null if it was nonexistent

    • newValue: string

      current value of the attribute. null if removed.

    Returns void

connectedCallback

  • connectedCallback(): void

disconnectedCallback

  • disconnectedCallback(): void

Optional Protected documentChanged

Private generateMutationId

  • generateMutationId(): number

Private getDOMGraphQLDocument

Private getDOMVariables

  • getDOMVariables(): V | null
  • Gets operation variables from the element's JSON script child

    Returns V | null

Private isMostRecentMutation

  • isMostRecentMutation(mutationId: number): boolean
  • Returns true when an ID matches the most recent mutation id.

    Parameters

    • mutationId: number

    Returns boolean

mutate

  • mutate(params?: Partial<MutationOptions<D, V>>): Promise<FetchResult<D>>
  • 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

    • Optional params: Partial<MutationOptions<D, V>>

    Returns Promise<FetchResult<D>>

Optional onCompleted

  • onCompleted(_data: D): void

Private onCompletedMutation

  • onCompletedMutation(mutationId: number, response: FetchResult<D>): FetchResult<D>
  • Callback for when a mutation is completed.

    Parameters

    • mutationId: number
    • response: FetchResult<D>

    Returns FetchResult<D>

Private onDOMMutation

  • onDOMMutation(records: MutationRecord[]): void

Optional onError

  • onError(_error: Error): void

Private onMutationError

  • onMutationError(mutationId: number, error: ApolloError): never

Optional updater

  • updater(...params: Parameters<MutationUpdaterFn<D>>): ReturnType<MutationUpdaterFn<D>>
  • Parameters

    • Rest ...params: Parameters<MutationUpdaterFn<D>>

    Returns ReturnType<MutationUpdaterFn<D>>

Optional Protected variablesChanged

  • variablesChanged(variables: V | null): void
  • Lifecycle callback that reacts to changes in the operation variables

    Parameters

    • variables: V | null

    Returns void