-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Added new JSONConvert enum to contain JSON-related operations.
- Loading branch information
1 parent
87e18e4
commit 2cf5f28
Showing
3 changed files
with
73 additions
and
4 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
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,21 @@ | ||
import Foundation | ||
#if !COCOAPODS | ||
import ApolloAPI | ||
#endif | ||
|
||
public enum JSONConvert { | ||
|
||
/// Converts a ``SelectionSet`` into a basic JSON dictionary for use. | ||
/// | ||
/// - Returns: A `[String: Any]` JSON dictionary representing the ``SelectionSet``. | ||
public static func selectionSetToJSONObject(_ selectionSet: some SelectionSet) -> [String: Any] { | ||
selectionSet.__data.asJSONDictionary() | ||
} | ||
|
||
/// Converts a ``GraphQLResult`` into a basic JSON dictionary for use. | ||
/// | ||
/// - Returns: A `[String: Any]` JSON dictionary representing the ``GraphQLResult``. | ||
public static func graphQLResultToJSONObject<T>(_ result: GraphQLResult<T>) -> [String: Any] { | ||
result.asJSONDictionary() | ||
} | ||
} |