UploadRequest
CLASS
UploadRequest
1open class UploadRequest<Operation: GraphQLOperation>: HTTPRequest<Operation>
A request class allowing for a multipart-upload request.
Properties
requestBodyCreator
1public let requestBodyCreator: RequestBodyCreator
files
1public let files: [GraphQLFile]
manualBoundary
1public let manualBoundary: String?
serializationFormat
1public let serializationFormat = JSONSerializationFormat.self
Methods
init(graphQLEndpoint:operation:clientName:clientVersion:additionalHeaders:files:manualBoundary:requestBodyCreator:)
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"
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. 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 providedApolloRequestBodyCreator
implementation.
Parameters
Name | Description |
---|---|
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. |
toURLRequest()
1public override func toURLRequest() throws -> URLRequest
requestMultipartFormData()
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