HTTPRequest
CLASS
HTTPRequest
1open class HTTPRequest<Operation: GraphQLOperation>Encapsulation of all information about a request before it hits the network
Properties
graphQLEndpoint
1open var graphQLEndpoint: URLThe endpoint to make a GraphQL request to
operation
1open var operation: OperationThe GraphQL Operation to execute
additionalHeaders
1open var additionalHeaders: [String: String]Any additional headers you wish to add by default to this request
cachePolicy
1open var cachePolicy: CachePolicyThe CachePolicy to use for this request.
contextIdentifier
1public let contextIdentifier: UUID?[optional] A unique identifier for this request, to help with deduping cache hits for watchers.
Methods
init(graphQLEndpoint:operation:contextIdentifier:contentType:clientName:clientVersion:additionalHeaders:cachePolicy:)
1public init(graphQLEndpoint: URL,
2 operation: Operation,
3 contextIdentifier: UUID? = nil,
4 contentType: String,
5 clientName: String,
6 clientVersion: String,
7 additionalHeaders: [String: String],
8 cachePolicy: CachePolicy = .default)Designated Initializer
Parameters:
graphQLEndpoint: The endpoint to make a GraphQL request to
operation: The GraphQL Operation to execute
contextIdentifier: [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to
nil.contentType: The
Content-Typeheader's value. Should usually be set for you by a subclass.clientName: The name of the client to send with the
"apollographql-client-name"headerclientVersion: The version of the client to send with the
"apollographql-client-version"headeradditionalHeaders: Any additional headers you wish to add by default to this request.
cachePolicy: The
CachePolicyto use for this request. Defaults to the.defaultpolicy
Parameters
| Name | Description |
|---|---|
| graphQLEndpoint | The endpoint to make a GraphQL request to |
| operation | The GraphQL Operation to execute |
| contextIdentifier | [optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to nil. |
| contentType | The Content-Type header’s value. Should usually be set for you by a subclass. |
| clientName | The name of the client to send with the "apollographql-client-name" header |
| clientVersion | The version of the client to send with the "apollographql-client-version" header |
| additionalHeaders | Any additional headers you wish to add by default to this request. |
| cachePolicy | The CachePolicy to use for this request. Defaults to the .default policy |
addHeader(name:value:)
1open func addHeader(name: String, value: String)updateContentType(to:)
1open func updateContentType(to contentType: String)toURLRequest()
1open func toURLRequest() throws -> URLRequestConverts this object to a fully fleshed-out URLRequest
Throws: Any error in creating the request
Returns: The URL request, ready to send to your server.