-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
92 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
AmplifyPlugins/Core/AWSPluginsCore/API/AWSAppSyncConfiguration.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Law, Michael on 2024-07-05. | ||
// | ||
|
||
import Foundation | ||
@_spi(InternalAmplifyConfiguration) import Amplify | ||
|
||
public struct AWSAppSyncConfiguration { | ||
public let region: String | ||
public let endpoint: URL | ||
public let apiKey: String? | ||
|
||
public init(with amplifyOutputs: AmplifyOutputs) throws { | ||
do { | ||
let resolvedConfiguration = try amplifyOutputs.resolveConfiguration() | ||
|
||
guard let dataCategory = resolvedConfiguration.data else { | ||
throw "" | ||
} | ||
|
||
self.region = dataCategory.awsRegion | ||
guard let endpoint = URL(string: dataCategory.url) else { | ||
throw "" | ||
} | ||
self.endpoint = endpoint | ||
self.apiKey = dataCategory.apiKey | ||
|
||
} catch { | ||
throw error | ||
} | ||
} | ||
|
||
static var isRunningForSwiftUIPreviews: Bool { | ||
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil | ||
} | ||
} | ||
|
||
|
||
extension AWSAppSyncConfiguration: DefaultLogger { } | ||
|
||
extension String: Error { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters