public protocol NetworkTransport: AnyObject
A network transport is responsible for sending GraphQL operations to a server.
var clientName: String
The name of the client to send as a header value.
var clientVersion: String
The version of the client to send as a header value.
func send<Operation: GraphQLOperation>(operation: Operation, cachePolicy: CachePolicy, contextIdentifier: UUID?, callbackQueue: DispatchQueue, completionHandler: @escaping (Result<GraphQLResult<Operation.Data>, Error>) -> Void) -> Cancellable
Send a GraphQL operation to a server and return a response.
Note if you're implementing this yourself rather than using one of the batteries-included versions of
NetworkTransport (which handle this for you): The
clientVersion should be sent with any URL request which needs headers so your client can be identified by tools meant to see what client is using which request. The
addApolloClientHeaders method is provided below to do this for you if you're using Apollo Studio.
- operation: The operation to send.
- cachePolicy: The
CachePolicyto use making this request.
- contextIdentifier: [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to
- callbackQueue: The queue to call back on with the results. Should default to
- completionHandler: A closure to call when a request completes. On
successwill contain the response received from the server. On
failurewill contain the error which occurred.
- Returns: An object that can be used to cancel an in progress request.
|operation||The operation to send.|
|contextIdentifier||[optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to |
|callbackQueue||The queue to call back on with the results. Should default to |
|completionHandler||A closure to call when a request completes. On |