-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(auth): parse and surface returned subscription @auth errors
When a subscription fails due to an authorization issue, parse and surface AppSyncJSONValue errors in order to let DataStore recover
- Loading branch information
Showing
6 changed files
with
87 additions
and
3 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
32 changes: 32 additions & 0 deletions
32
AmplifyPlugins/API/AWSAPICategoryPlugin/Support/Utils/AppSyncJSONValue+toJSONValue.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,32 @@ | ||
// | ||
// Copyright 2018-2020 Amazon.com, | ||
// Inc. or its affiliates. All Rights Reserved. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
import Foundation | ||
import Amplify | ||
import AppSyncRealTimeClient | ||
|
||
extension AppSyncJSONValue { | ||
static func toJSONValue(_ json: AppSyncJSONValue) -> JSONValue { | ||
switch json { | ||
case .array(let values): | ||
return JSONValue.array(values.map(AppSyncJSONValue.toJSONValue)) | ||
case .boolean(let value): | ||
return JSONValue.boolean(value) | ||
case .null: | ||
return JSONValue.null | ||
case .number(let value): | ||
return JSONValue.number(value) | ||
case .object(let content): | ||
return JSONValue.object(content.reduce(into: [:]) { acc, partial in | ||
let (key, value) = partial | ||
acc[key] = AppSyncJSONValue.toJSONValue(value) | ||
}) | ||
case .string(let value): | ||
return JSONValue.string(value) | ||
} | ||
} | ||
} |
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
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