UploadRequest


CLASS

UploadRequest

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

A request class allowing for a multipart-upload request.

Properties

requestBodyCreator

Swift
1public let requestBodyCreator: RequestBodyCreator

files

Swift
1public let files: [GraphQLFile]

manualBoundary

Swift
1public let manualBoundary: String?

serializationFormat

Swift
1public let serializationFormat = JSONSerializationFormat.self

Methods

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

Swift
1public init(graphQLEndpoint: URL,
2            operation: Operation,
3            clientName: String,
4            clientVersion: String,
5            additionalHeaders: [String: String] = [:],
6            files: [GraphQLFile],
7            manualBoundary: String? = nil,
8            requestBodyCreator: RequestBodyCreator = ApolloRequestBodyCreator())

Designated Initializer

  • Parameters:

    • graphQLEndpoint: The endpoint to make a GraphQL request to

    • operation: The GraphQL 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 mutation.

    • 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()

Swift
1public override func toURLRequest() throws -> URLRequest

requestMultipartFormData()

Swift
1open 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

Feedback

Edit on GitHub

Forums