Docs
Launch GraphOS Studio


CLASS

UploadRequest

open class UploadRequest<Operation: GraphQLOperation>: HTTPRequest<Operation>

A request class allowing for a multipart-upload request.

Properties

requestBodyCreator

public let requestBodyCreator: RequestBodyCreator

files

public let files: [GraphQLFile]

manualBoundary

public let manualBoundary: String?

serializationFormat

public let serializationFormat = JSONSerializationFormat.self

Methods

init(graphQLEndpoint:operation:clientName:clientVersion:additionalHeaders:files:manualBoundary:requestBodyCreator:)

public init(graphQLEndpoint: URL,
operation: Operation,
clientName: String,
clientVersion: String,
additionalHeaders: [String: String] = [:],
files: [GraphQLFile],
manualBoundary: String? = nil,
requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator())

Designated Initializer

  • Parameters:
    • Endpoint: The endpoint to make a GraphQL request to
    • : The Operation to execute
    • 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. Defaults to an empty dictionary.
    • files: The array of files to upload for all Upload parameters in the .
    • manualBoundary: [optional] A manual boundary to pass in. A default boundary will be used otherwise. Defaults to nil.
    • requestBodyCreator: An object conforming to the RequestBodyCreator protocol to assist with creating the request body. Defaults to the provided ApolloRequestBodyCreator implementation.

Parameters

NameDescription
graphQLEndpointThe endpoint to make a GraphQL request to
operationThe GraphQL Operation to execute
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. Defaults to an empty dictionary.
filesThe array of files to upload for all Upload parameters in the mutation.
manualBoundary[optional] A manual boundary to pass in. A default boundary will be used otherwise. Defaults to nil.
requestBodyCreatorAn object conforming to the RequestBodyCreator protocol to assist with creating the request body. Defaults to the provided ApolloRequestBodyCreator implementation.

toURLRequest()

public override func toURLRequest() throws -> URLRequest

requestMultipartFormData()

open func requestMultipartFormData() throws -> MultipartFormData

Creates the MultipartFormData object to use when creating the URL Request.

This method follows the GraphQL Multipart Request Spec Override this method to use a different upload spec.

  • Throws: Any error arising from creating the form data
  • Returns: The created form data

==(_:_:)

public static func == (lhs: UploadRequest<Operation>, rhs: UploadRequest<Operation>) -> Bool

hash(into:)

public override func hash(into hasher: inout Hasher)
Next
Introduction
Edit on GitHubEditForumsDiscord

© 2024 Apollo Graph Inc.

Privacy Policy

Company