Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added correct way of default parameters #804

31 changes: 30 additions & 1 deletion Sources/Apollo/RequestCreator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ public protocol RequestCreator {
}

extension RequestCreator {
/// Creates a `GraphQLMap` out of the passed-in operation
///
/// - Parameters:
/// - operation: The operation to use
/// - Returns: The created `GraphQLMap`
public func requestBody<Operation: GraphQLOperation>(for operation: Operation) -> GraphQLMap {
return requestBody(for: operation, sendOperationIdentifiers: false)
designatednerd marked this conversation as resolved.
Show resolved Hide resolved
}

/// Creates a `GraphQLMap` out of the passed-in operation
///
/// - Parameters:
Expand All @@ -52,6 +61,26 @@ extension RequestCreator {
return body
}

/// Creates multi-part form data to send with a request
///
/// - Parameters:
/// - operation: The operation to create the data for.
/// - files: An array of files to use.
/// - sendOperationIdentifiers: True if operation identifiers should be sent, false if not.
/// - serializationFormat: The format to use to serialize data.
/// - Returns: The created form data
/// - Throws: Errors creating or loading the form data
public func requestMultipartFormData<Operation: GraphQLOperation>(for operation: Operation,
files: [GraphQLFile],
sendOperationIdentifiers: Bool,
serializationFormat: JSONSerializationFormat.Type) throws -> MultipartFormData {
return try requestMultipartFormData(for: operation,
files: files,
sendOperationIdentifiers: sendOperationIdentifiers,
serializationFormat: serializationFormat,
manualBoundary: nil)
designatednerd marked this conversation as resolved.
Show resolved Hide resolved
}

/// Creates multi-part form data to send with a request
///
/// - Parameters:
Expand All @@ -66,7 +95,7 @@ extension RequestCreator {
files: [GraphQLFile],
sendOperationIdentifiers: Bool,
serializationFormat: JSONSerializationFormat.Type,
manualBoundary: String? = nil) throws -> MultipartFormData {
manualBoundary: String?) throws -> MultipartFormData {
let formData: MultipartFormData

if let boundary = manualBoundary {
Expand Down