APICategoryGraphQLBehavior

public protocol APICategoryGraphQLBehavior : AnyObject

Behavior of the API category related to GraphQL operations

Request-based GraphQL Operations

  • 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

    @discardableResult
    func query<R: Decodable>(request: GraphQLRequest<R>,
                             listener: GraphQLOperation<R>.ResultListener?) -> GraphQLOperation<R>

    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 mutate operation against a previously configured API. This operation will be asynchronous, with the callback accessible both locally and via the Hub.

    Declaration

    Swift

    @discardableResult
    func mutate<R: Decodable>(request: GraphQLRequest<R>,
                              listener: GraphQLOperation<R>.ResultListener?) -> GraphQLOperation<R>

    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>,
                                 valueListener: GraphQLSubscriptionOperation<R>.InProcessListener?,
                                 completionListener: GraphQLSubscriptionOperation<R>.ResultListener?)
        -> GraphQLSubscriptionOperation<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

  • query(request:) Extension method

    Default implementation of query to provide convenience for passing nil arguments.

    Declaration

    Swift

    public func query<R>(request: GraphQLRequest<R>) -> GraphQLOperation<R> where R : Decodable

    Parameters

    request

    GraphQL request

    Return Value

    GraphQL operation

  • mutate(request:) Extension method

    Default implementation of mutate to provide convenience for passing nil arguments.

    Declaration

    Swift

    public func mutate<R>(request: GraphQLRequest<R>) -> GraphQLOperation<R> where R : Decodable

    Parameters

    request

    GraphQL request

    Return Value

    GraphQL operation

  • subscribe(request:) Extension method

    Default implementation of subscribe to provide convenience for passing nil arguments.

    Declaration

    Swift

    public func subscribe<R>(request: GraphQLRequest<R>) -> GraphQLSubscriptionOperation<R> where R : Decodable

    Parameters

    request

    GraphQL request

    Return Value

    GraphQL operation