Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PolymerApolloMutation<TData, TVariables>

element

apollo-mutation

<apollo-mutation> fires Polymer-style prop-changed events when its called, data, error, loading or networkStatus properties change.

example
<apollo-mutation id="userMutation" data="{{data}}">
  <script type="application/graphql">
    mutation User($id: ID!, $name: String, $picture: String) {
      user(id: $id, name: $name, picture: $picture) {
        name
        picture
      }
    }
  </script>
</apollo-mutation>

<paper-input label="Name" value="{{name}}"></paper-input>
<paper-input label="Picture URL" value="{{picture}}"></paper-input>
<paper-button on-click="mutate">Submit</paper-button>
fires

'apollo-element-disconnected' when the element disconnects from the dom

fires

'apollo-element-connected' when the element connects to the dom

fires

'data-changed'

fires

'error-changed'

fires

'errors-changed'

fires

'loading-changed'

fires

'called-changed'

Type parameters

  • TData

  • TVariables

Hierarchy

Implements

Index

Constructors

constructor

Properties

Private __document

__document: DocumentNode = null

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 = null

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

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

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

Optional updater

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

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

    Returns ReturnType<MutationUpdaterFn<TData>>