CLASS
HTTPRequest
open class HTTPRequest<Operation: GraphQLOperation>
Encapsulation of all information about a request before it hits the network
Properties
graphQLEndpoint
open var graphQLEndpoint: URL
The endpoint to make a GraphQL request to
operation
open var operation: Operation
The GraphQL Operation to execute
additionalHeaders
open var additionalHeaders: [String: String]
Any additional headers you wish to add by default to this request
cachePolicy
public let cachePolicy: CachePolicy
The
CachePolicy
to use for this request.
contextIdentifier
public 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:)
public init(graphQLEndpoint: URL,
operation: Operation,
contextIdentifier: UUID? = nil,
contentType: String,
clientName: String,
clientVersion: String,
additionalHeaders: [String: String],
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-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
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:)
open func addHeader(name: String, value: String)
updateContentType(to:)
open func updateContentType(to contentType: String)
toURLRequest()
open func toURLRequest() throws -> URLRequest
Converts 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.