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
ApolloDebugServerinstance.Declaration
Swift
public convenience init(networkTransport: DebuggableNetworkTransport, cache: DebuggableNormalizedCache)Parameters
networkTransportAn underlying network transport object.
cacheAn 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,serverURLmight returnnil. Since there’s no way to access host machine’s network interfaces,ApolloDebugServerassumesen0oren1is the only available interfaces.See also
ApolloDebugServer.serverURLsDeclaration
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
POSIXErrorwhen an error occurred while setting up a socket.Declaration
Swift
public func start(port: UInt16) throwsParameters
portA 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
HTTPServerErrorwhen an error occurred while setting up a socket. *Declaration
Swift
public func start<T>(randomPortIn ports: T) throws -> UInt16 where T : Collection, T.Element == UInt16Parameters
portsA 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()
-
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
ApolloDebugServer Class Reference