Bot releases are hidden (Show)
lastSyncTime
. See issue #232
Support multiple authorization modes for a single AWS AppSync GraphQL endpoint.
Breaking API Change Introduced clientDatabasePrefix
in the AWSAppSyncServiceConfigProvider
that accepts a prefix that will be used in the construction of database name for caching query responses, offline mutations and subscriptions metadata. The usage of the prefix can be enabled by the flag useClientDatabasePrefix: true
as part of the AWSAppSyncCacheConfiguration
. When the prefix is used, the name of the database would look as follows:
Purpose of cache | No prefix | Valid prefix |
---|---|---|
Query responses | queries.db |
<ClientDatabasePrefix>_queries.db |
Offline Mutations | offlineMutations.db |
<ClientDatabasePrefix>_offlineMutations.db |
Subscriptions metadata for Delta Sync | subscriptionMetadataCache.db |
<ClientDatabasePrefix>_subscriptionMetadataCache.db |
The ClientDatabasePrefix
can be passed via awsconfiguration.json
that is generated from the AWS AppSync Console and Amplify CLI.
"AppSync": {
"Default": {
"ApiUrl": "https://xyz.appsync-api.us-east-2.amazonaws.com/graphql",
"Region": "us-east-2",
"AuthMode": "API_KEY",
"ApiKey": "da2-xyz",
"ClientDatabasePrefix": "MyAppSyncAPIName_API_KEY"
}
}
The AWSAppSyncClient
object can be constructed as follows:
let serviceConfigAPIKey = try AWSAppSyncServiceConfig()
let cacheConfigAPIKey = try AWSAppSyncCacheConfiguration(useClientDatabasePrefix: true,
appSyncServiceConfig: serviceConfigAPIKey!)
let clientConfigAPIKey = try AWSAppSyncClientConfiguration(appSyncServiceConfig: serviceConfigAPIKey!,
cacheConfiguration: cacheConfigAPIKey!)
let clientAPIKey = try AWSAppSyncClient(appSyncConfig: clientConfigAPIKey!)
Deprecated clearCache()
please use clearCaches(options:)
instead. This new method will clear the query responses, offline mutations and subscriptions metadata by default and the options parameter can be used to fine-tune the operation.
cancel
and when SDK notifies connectionError
in the statusChangeHandler
and resultHandler
statusChangeHandler
and resultHandler
for the subscription, issue a cancel
which would immediately stop all communication to the watcher.cancel
is issued, no notifications or error callbacks will be given to the watcher. If the watcher object is not reference from application code, it will internally issue a cancel
and ensure that no callbacks are given.Breaking Build Environment Changes
Other changes
Behavior Change for Mutation Queue
always
attempt to make a mutation request regardless of the network stateNSURLSession
and determine if the error was due to network not available, host not found or DNS lookup failed. If it was, the SDK will schedule a retry timer responsible to retry the request which will grow exponentially with every attemptNSURLSession
errors so that retry can be scheduledNSURLErrorDomain
in the domain
field and the indicated error code in code
field.retryStrategy
parameter in AWSAppSyncClientConfiguration
. You can choose between aggressive
and exponential
(default selection).uniqueIdentifier
field in AWSSubscriptionWatcher
as public which was incorrectly marked private in previous version.subscribe
method now accepts an optional statusChangeHandler
. If provided, then the AWSAppSyncSubscriptionWatcher
subscribe
method will invoke that method when it is notified of changes to the state of the underlying MQTT client.AWSAppSyncSubscriptionWatcherStatus
for a description of the statuses and their progression. Thanks @fans3210, @shannon-hager-skookum, and @achager forqueuedMutationCount
property to AppSyncClient (Issue #192)Added AWSAppSyncClientLogFormatter
utility class. Developers who want to use it can add it to the appropriate logger. For example, a configuration like:
AWSDDLog.sharedInstance.logLevel = .verbose
AWSDDTTYLogger.sharedInstance.logFormatter = AWSAppSyncClientLogFormatter()
AWSDDLog.sharedInstance.add(AWSDDTTYLogger.sharedInstance)
would output log messages like:
2019-03-04 07:21:32.131-0800 [I AWSAppSyncClient.init(appSyncConfig:reachabilityFactory:), L75] Initializing AppSyncClient
2019-03-04 07:21:32.135-0800 [V AWSPerformMutationQueue.init(appSyncClient:networkClient:reachabiltyChangeNotifier:cacheFileURL:), L24] Initializing AWSPerformMutationQueue
2019-03-04 07:21:32.135-0800 [V AWSPerformMutationQueue.resume(), L95] Resuming OperationQueue
Please note that verbose
logging is quite verbose, and there is a significant difference between verbose
and debug
. We will be making
debug
more useful as we go. (See Issue #145)
As always, we recommend turning off logging when deploying to production.
Added some verbose logging around mutation queue handling and subscription connections; minor log additions elsewhere
Minor dead code removal & miscellaneous cleanup
"."
) in the arguments were not being properly cached (Issue #110, #165)AWSAppSyncClient.perform(mutation:queue:optimisticUpdate:conflictResolutionBlock:resultHandler:)
now properly invokes its result handler callbacks on the supplied queue
instead of always using DispatchQueue.main
Prepopulate the queries cache with an empty QUERY_ROOT
record, to allow optimistic updates of the cache where no queries have been previously performed. (Issue #92, #101)
Fix how "cache hits" are determined in queries, to match Apollo behavior. (#90)
A "cache hit" is defined as all members of the selection set having a non-nil value. For a simple query, (e.g., the HeroNameQuery
of the StarWars API), that is an easy mental map:
Cache hit
{
"QUERY_ROOT": { "hero": "#hero" },
"#hero": { "hero": {"name": "R2-D2", "__typename": "Droid"} }
}
Cache misses
{}
{ "QUERY_ROOT": null }
{ "QUERY_ROOT": {} }
{
"QUERY_ROOT": { "hero": "#hero" },
"#hero": { "hero": null }
}
// Misses because type data is incomplete
{
"QUERY_ROOT": { "hero": "#hero" },
"#hero": { "hero": {"name": "R2-D2"} }
}
For more complex queries (like the TwoHeroesQuery
), only all values being non-nil will result in a cache hit:
Cache Hit
{
"QUERY_ROOT": {
"hero": "#hero",
"hero(episode:EMPIRE)": "#hero(episode:EMPIRE)"
},
"#hero": {"name": "R2-D2", "__typename": "Droid"},
"#hero(episode:EMPIRE)": {"name": "Luke Skywalker", "__typename": "Human"}
}
Cache Misses
{}
{ "QUERY_ROOT": null }
{ "QUERY_ROOT": {} }
{
"QUERY_ROOT": { "hero": "#hero" },
"#hero": { "hero": null }
}
{
"QUERY_ROOT": {
"hero": "#hero"
},
"#hero": {"name": "R2-D2", "__typename": "Droid"}
}
These definitions match the existing Apollo behavior, as verified in additional tests against the
unmodified Apollo codebase.
AWSAppSyncCacheConfiguration
AppSync persistent caches for queries (used by the Apollo store), mutations,
and subscription metadata are now stored in separate files. A new
AWSAppSyncCacheConfiguration
API has been added that allows clients to
specify persistent caches for all, some, or none of these caches:
// Specify persistent caches that live in the app's Cache directory
let cacheConfiguration = try AWSAppSyncCacheConfiguration()
// ... or specify persistent caches that live in `rootDirectory`
let cacheConfiguration = try AWSAppSyncCacheConfiguration(withRootDirectory: rootDirectory)
// ... or specify a database path for the query cache and the subscriptionMetadata cache, but an in-memory cache for mutation queue
let cacheConfiguration = AWSAppSyncCacheConfiguration(offlineMutations: nil,
queries: queriesDatabasePath,
subscriptionMetadataCache: subscriptionDatabasePath)
// ... or specify all caches to be in-memory
let cacheConfiguration = AWSAppSyncCacheConfiguration.inMemory
// ... then use the cache config in the AWSAppSyncClientConfiguration constructor
let appSyncConfig = try AWSAppSyncClientConfiguration(appSyncServiceConfig: serviceConfig, cacheConfiguration: cacheConfiguration)
let appSyncClient = AWSAppSyncClient(appSyncConfig: appSyncConfig)
// Alternately, specify all in-memory caches by passing no `cacheConfiguration`
let appSyncConfig = try AWSAppSyncClientConfiguration(appSyncServiceConfig: serviceConfig)
let appSyncClient = AWSAppSyncClient(appSyncConfig: appSyncConfig)
Migration
Clients can migrate to the new AWSAppSyncCacheConfiguration with a utility
method that performs a one-time move of data from the previous databaseURL to
the new cache configuration directory:
// Specify persistent caches that live in the app's Cache directory
let cacheConfiguration = try AWSAppSyncCacheConfiguration()
let databaseURL = // whatever your old databaseURL was
// Upon successful completion, this method sets a flag in UserDefaults, making it safe
// to call at startup for as long as this method exists.
AWSAppSyncCacheConfigurationMigration.migrate(from: databaseURL, to: cacheConfiguration)
Breaking API Changes
AWSSQLLiteNormalizedCacheError
has been renamed toAWSAppSyncQueriesCacheError
. Error conditions during manipulations of theDeprecations
AWSSQLLiteNormalizedCache
is deprecated and will be removed in anAWSAppSyncCacheConfiguration
to get the path of the appropriate databasedatabaseURL
option to AWSAppSyncClientConfiguration
is deprecated.cacheConfiguration
option (See above)MutationCache
protocol is deprecated because it is unused.AWSAppSyncClient.clearCache()
method to clear the local Apollo cache. See Issue #36, PR #141 Thanks @larryonoff! 🎉handlerQueue
instead of always using DispatchQueue.main
VALID_ARCH
in its build settings but instead uses defaults. See PR#156 Thanks @larryonoff! 🎉pod update
before building (#150)This release also includes changes from the previous, broken release, 2.9.0:
OperationQueue
, to fix cases where mutations would either deadlock (#81), or not execute (#106). Thanks @larryonoff! 🎉Breaking API Changes
AWSPerformMutationOperation
was public
, now it's internal
AWSAppSyncClient.perform
now returns Cancellable
instead of AWSPerformMutationOperation
Refactored internal network change notifications (#139)
Refactored structure & tests to make future maintenance easier. As part of this, we deprecated the AWSAppSyncClientInfo
class in favor of the AWSAppSyncServiceConfigProvider
protocol. We provide a default implementation AWSAppSyncServiceConfig
. AWSAppSyncClientInfo
will be removed in a future minor version.
Refactored tests into Unit and Integration tests. Currently, any test that requires network activity is placed in Integration tests, even if the test hits localhost and not a valid service.
AWSAppSync.podspec
file incorrectly declares a dependency on version 2.9.0 of AWSCore
. The correct dependency version is 2.8.0, and is updated in the CocoaPods trunk spec repo.Published by desokroshan almost 6 years ago
This release has been deprecated. Carthage build failed for this release. Please use 2.9.1 instead.
Float.random(in:)
instead of arc4random()
to generate request retry jitter. See PR #108. Thanks @larryonoff! 🎉SyncConfiguration
:
class
to a struct
defaultSyncConfiguration
method has been removed. Create a default configuration by invoking the initializer with no arguments, SyncConfiguration()
Published by rohandubal almost 6 years ago
SWIFT_VERSION
was officially set to 3. This change makes the support explicit in the project files and README.