ApolloDebugServer

public class ApolloDebugServer
extension ApolloDebugServer: DebuggableNetworkTransportDelegate

ApolloDebugServer is a HTTP server to communicate with apollo-client-devtools.

The server works even after the app moves to the background for a while. When the server is released, it stops itself automatically.

  • Initializes ApolloDebugServer instance.

    Declaration

    Swift

    public convenience init(networkTransport: DebuggableNetworkTransport, cache: DebuggableNormalizedCache)

    Parameters

    networkTransport

    An underlying network transport object.

    cache

    An underlying cache object.

  • A Boolean value indicating whether the server is running or not.

    Declaration

    Swift

    public var isRunning: Bool { get }
  • The URL where the server is established. Only returns resolved hostname in IPv4 format.

    Warning

    If running on a simulator, serverURL might return nil. Since there’s no way to access host machine’s network interfaces, ApolloDebugServer assumes en0 or en1 is the only available interfaces.

    Declaration

    Swift

    public var serverURL: URL? { get }
  • The possible URLs where the server is established.

    The hostname may contain resolved IPv4 / IPv6 format.

    Declaration

    Swift

    public var serverURLs: [URL] { get }
  • Enables console redirection (disabled by default).

    When console redirection is enabled, all logs written in stdout and stderr are redirected to the web browser’s console. Console redirection will stop when the server is released from the memory but won’t stop when the server just stops.

    Warning

    This is an experimental feature for now, so please do not rely on the behavior.

    Declaration

    Swift

    public var enableConsoleRedirection: Bool { get set }
  • Starts HTTP server listening on the given port.

    This method should be invoked on the main thread. The server automatically stops and restarts when it’s already running.

    Throws

    POSIXError when an error occurred while setting up a socket.

    Declaration

    Swift

    public func start(port: UInt16) throws

    Parameters

    port

    A port number. Avoid using well-known ports.

  • Starts HTTP server listening on a random port in the given range.

    This method should be invoked on the main thread.

    Throws

    HTTPServerError when an error occurred while setting up a socket. *

    Declaration

    Swift

    public func start<T>(randomPortIn ports: T) throws -> UInt16 where T : Collection, T.Element == UInt16

    Parameters

    ports

    A range of ports. Avoid using well-known ports.

  • Stops the server from running.

    This method should be invoked on the main thread. It’s safe if you invoke this method even while the server isn’t running.

    Declaration

    Swift

    public func stop()

DebuggableNetworkTransportDelegate

  • Undocumented

    Declaration

    Swift

    public func networkTransport<Operation>(_ networkTransport: NetworkTransport, willSendOperation operation: Operation) where Operation : GraphQLOperation
  • Undocumented

    Declaration

    Swift

    public func networkTransport<Operation>(_ networkTransport: NetworkTransport, didSendOperation operation: Operation, result: Result<GraphQLResult<Operation.Data>, Error>) where Operation : GraphQLOperation