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

ApolloSQLite -> Fix deserialize method for custom scalars #1144

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Sources/ApolloSQLite/SQLiteNormalizedCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Apollo
public enum SQLiteNormalizedCacheError: Error {
case invalidRecordEncoding(record: String)
case invalidRecordShape(object: Any)
case invalidRecordValue(value: Any)
}

/// A `NormalizedCache` implementation which uses a SQLite database to store data.
Expand Down
2 changes: 1 addition & 1 deletion Sources/ApolloSQLite/SQLiteSerialization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final class SQLiteSerialization {
switch fieldJSONValue {
case let dictionary as JSONObject:
guard let reference = dictionary[serializedReferenceKey] as? String else {
throw SQLiteNormalizedCacheError.invalidRecordValue(value: fieldJSONValue)
return fieldJSONValue
}
return Reference(key: reference)
case let array as [JSONValue]:
Expand Down
21 changes: 3 additions & 18 deletions Tests/ApolloCacheDependentTests/LoadQueryFromStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -298,26 +298,11 @@ class LoadQueryFromStoreTests: XCTestCase, CacheTesting {
XCTFail("Incorrect error type for primary error: \(error)")
return
}

switch graphQLError.underlying {
case is JSONDecodingError:
if (cache is InMemoryNormalizedCache) {
// This is expected for in-memory caching
break
} else {
XCTFail("Incorrect error type for underlying with in-memory cache: \(graphQLError.underlying)")
}
#if canImport(ApolloSQLite)
case is SQLiteNormalizedCacheError:
if (cache is SQLiteNormalizedCache) {
// This is expected for SQLite caching
break
} else {
XCTFail("Incorrect error type for underlying with SQLite cache: \(graphQLError.underlying)")
}
#endif
case JSONDecodingError.couldNotConvert(value: _, to: _):
break
default:
XCTFail("Incorrect error type for underlying: \(graphQLError.underlying)")
XCTFail("Invalid error type")
}
}
}
Expand Down