forked from apollographql/apollo-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApolloSchemaDownloader.swift
More file actions
25 lines (20 loc) · 896 Bytes
/
ApolloSchemaDownloader.swift
File metadata and controls
25 lines (20 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import Foundation
// Only available on macOS
#if os(macOS)
/// A wrapper to facilitate downloading a schema with the Apollo node CLI
public struct ApolloSchemaDownloader {
/// Runs code generation from the given folder with the passed-in options
///
/// - Parameters:
/// - cliFolderURL: The folder where the Apollo CLI is/should be downloaded.
/// - options: The `ApolloSchemaOptions` object to use to download the schema.
/// - Returns: Output from a successful run
@discardableResult
public static func run(with cliFolderURL: URL,
options: ApolloSchemaOptions) throws -> String {
try FileManager.default.apollo.createContainingFolderIfNeeded(for: options.outputURL)
let cli = try ApolloCLI.createCLI(cliFolderURL: cliFolderURL, timeout: options.downloadTimeout)
return try cli.runApollo(with: options.arguments)
}
}
#endif