Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ApolloMutation<TData, TVariables>

ApolloMutation

👩‍🚀 Custom element base class to issue mutations via your Apollo cache.

Type parameters

  • TData

  • TVariables

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private __data

__data: TData = null

Private __document

__document: DocumentNode = null

Private __error

__error: Error | ApolloError = null

Private __errors

__errors: readonly GraphQLError[] = null

Private __loading

__loading: boolean = false

Private __mo

Optional awaitRefetchQueries

awaitRefetchQueries: boolean

called

called: boolean = false

client

Optional context

context: Record<string, unknown>

data

data: TData

error

error: Error

Optional errorPolicy

errorPolicy: ErrorPolicy

errors

errors: readonly GraphQLError[]

Optional fetchPolicy

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

ignoreResults

ignoreResults: boolean = false

loading

loading: boolean

mostRecentMutationId

mostRecentMutationId: number = 0

mutation

mutation: DocumentNode

Optional optimisticResponse

optimisticResponse: TData | ((vars: TVariables) => TData)

Optional refetchQueries

refetchQueries: RefetchQueryDescription | ((result: FetchResult<TData>) => RefetchQueryDescription)

variables

variables: TVariables

Static Readonly is

is: string

Accessors

document

Methods

Optional adoptedCallback

  • adoptedCallback(): 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

createRenderRoot

  • createRenderRoot(): ReturnType<HTMLElement["attachShadow"]> | Node

disconnectedCallback

  • disconnectedCallback(): void

Private generateMutationId

  • generateMutationId(): number
  • Increments and returns the most recent mutation id.

    Returns number

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<TData, TVariables>>): Promise<FetchResult<TData>>
  • 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<TData, TVariables>>

    Returns Promise<FetchResult<TData>>

Optional onCompleted

  • onCompleted(_data: TData): void
  • Parameters

    • _data: TData

    Returns void

Private onCompletedMutation

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

    Parameters

    • response: FetchResult<TData>
    • mutationId: number

    Returns FetchResult<TData>

Optional onError

  • onError(_error: Error): void
  • Parameters

    Returns void

Private onMutationError

  • onMutationError(error: ApolloError, mutationId: number): never
  • Callback for when a mutation fails.

    Parameters

    Returns never

render

  • render(options?: { sync: boolean }): Promise<void>
  • Parameters

    • Optional options: { sync: boolean }
      • sync: boolean

    Returns Promise<void>

Optional updater

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

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

    Returns ReturnType<MutationUpdaterFn<TData>>