Docs
Launch GraphOS Studio
You're viewing documentation for a previous version of this software. Switch to the latest stable version.


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 request to

operation

open var operation: Operation

The GraphQL to execute

additionalHeaders

open var additionalHeaders: [String: String]

Any additional headers you wish to add by default to this request

cachePolicy

open var 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:
    • Endpoint: The endpoint to make a GraphQL request to
    • : 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

NameDescription
graphQLEndpointThe endpoint to make a GraphQL request to
operationThe GraphQL Operation to execute
contextIdentifier[optional] A unique identifier for this request, to help with deduping cache hits for watchers. Defaults to nil.
contentTypeThe Content-Type header’s value. Should usually be set for you by a subclass.
clientNameThe name of the client to send with the "apollographql-client-name" header
clientVersionThe version of the client to send with the "apollographql-client-version" header
additionalHeadersAny additional headers you wish to add by default to this request.
cachePolicyThe 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.
Next
Introduction
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company