HTTPRequest
CLASS
HTTPRequest
1open class HTTPRequest<Operation: GraphQLOperation>: Hashable
Encapsulation of all information about a request before it hits the network
Properties
graphQLEndpoint
1open var graphQLEndpoint: URL
The endpoint to make a GraphQL request to
operation
1open var operation: Operation
The 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: CachePolicy
The 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-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"
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
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:)
1open func addHeader(name: String, value: String)
updateContentType(to:)
1open func updateContentType(to contentType: String)
toURLRequest()
1open 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.
hash(into:)
1public func hash(into hasher: inout Hasher)
Parameters
Name | Description |
---|---|
hasher | The hasher to use when combining the components of this instance. |
==(_:_:)
1public static func == (lhs: HTTPRequest<Operation>, rhs: HTTPRequest<Operation>) -> Bool
Parameters
Name | Description |
---|---|
lhs | A value to compare. |
rhs | Another value to compare. |