APICategoryGraphQLBehavior

public protocol APICategoryGraphQLBehavior : AnyObject, Sendable

Behavior of the API category related to GraphQL operations

Note

Sendable because the implementing plugin is Sendable (see Plugin) and DataStore holds this behavior across task boundaries throughout the sync engine.

Request-based GraphQL Operations

  • query(request:) Asynchronous

    Perform a GraphQL query operation against a previously configured API. This operation will be asynchronous, with the callback accessible both locally and via the Hub.

    Declaration

    Swift

    func query<R>(request: GraphQLRequest<R>) async throws -> GraphQLTask<R>.Success where R : Decodable, R : Sendable

    Parameters

    request

    The GraphQL request containing apiName, document, variables, and responseType

    listener

    The event listener for the operation

    Return Value

    The AmplifyOperation being enqueued

  • mutate(request:) Asynchronous

    Perform a GraphQL mutate operation against a previously configured API. This operation will be asynchronous, with the callback accessible both locally and via the Hub.

    Declaration

    Swift

    func mutate<R>(request: GraphQLRequest<R>) async throws -> GraphQLTask<R>.Success where R : Decodable, R : Sendable

    Parameters

    request

    The GraphQL request containing apiName, document, variables, and responseType

    listener

    The event listener for the operation

    Return Value

    The AmplifyOperation being enqueued

  • Perform a GraphQL subscribe operation against a previously configured API. This operation will be asychronous, with the callback accessible both locally and via the Hub.

    Declaration

    Swift

    func subscribe<R: Decodable>(
        request: GraphQLRequest<R>
    ) -> AmplifyAsyncThrowingSequence<GraphQLSubscriptionEvent<R>>

    Parameters

    request

    The GraphQL request containing apiName, document, variables, and responseType

    valueListener

    Invoked when the GraphQL subscription receives a new value from the service

    completionListener

    Invoked when the subscription has terminated

    Return Value

    The AmplifyInProcessReportingOperation being enqueued