I'm working on a React Native, AWS, DynamoDB, Amplify project, and I'm struggleing to add extra tables (models) to the database.
The original schema was quite simple. (maybe too simple to be effective)
type Capture @model {
id: ID!
captureID: String!
userID: String!
moodScore: String
emotion: String
lifeAspect: String
activity: String
companions: String
location: String
date: String
images: String
journalEntry: String
}
Users keep capturing moments of their life. Everything is stored as a String (for some reason...).
I'm trying to add more tables to the app. The new tables are not really connected to the current table. The only thing connecting the data us the UserID, that we got from "amplify/auth" when the user is logged in.
I added a 2nd model to the schema.graphql:
type Capture @model {
id: ID!
captureID: String!
userID: String!
moodScore: String
emotion: String
lifeAspect: String
activity: String
companions: String
location: String
date: String
images: String
journalEntry: String
}
type DbConversion @model {
id: ID!
userID: String!
ConversionID: [String!]
}
I don't want the tables to be connected in DynameDB. I want to use DataStore to only load the current user's data when the user is logged in.
let uuID = '';
// Configure datastore to sync based on user identifier.
DataStore.configure({
syncExpressions: [
syncExpression(Capture, () => {
return (capture) => capture.userID('eq', uuID);
}),
syncExpression(DbConversion, () => {
return (dbconversion) => dbconversion.userID('eq', uuID);
}),
],
});
// Retrieve user ID and reset datastore sync with new data for uuID.
export async function changeSync() {
uuID = await getData('userID');
await DataStore.stop();
await DataStore.start();
}
Everything was working fine until I tried adding the 2nd table. After that, I started getting huge warning messages:
[WARN] 37:23.730 DataStore - subscriptionError, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field '_version' in type 'Capture' is undefined @ 'onCreateCapture/_version'"},{"message":"Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'Capture' is undefined @ 'onCreateCapture/_lastChangedAt'"},{"message":"Validation error of type FieldUndefined: Field '_deleted' in type 'Capture' is undefined @ 'onCreateCapture/_deleted'"}]}
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\@aws-amplify\core\lib-esm\Logger\ConsoleLogger.js:138:12 in prototype._log
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:146334:21 in warn
at node_modules\@aws-amplify\datastore\lib-esm\sync\processors\subscription.js:357:87 in queryObservable.map.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\zen-observable\lib\Observable.js:329:17 in _this2.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\PubSub.js:180:37 in observable.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\Providers\AWSAppSyncRealTimeProvider.js:507:12 in prototype._handleIncomingSubscriptionMessage
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\WebSocket\WebSocket.js:231:8 in _eventEmitter.addListener$argument_1
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
[WARN] 37:23.830 DataStore - subscriptionError, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field '_version' in type 'Capture' is undefined @ 'onUpdateCapture/_version'"},{"message":"Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'Capture' is undefined @ 'onUpdateCapture/_lastChangedAt'"},{"message":"Validation error of type FieldUndefined: Field '_deleted' in type 'Capture' is undefined @ 'onUpdateCapture/_deleted'"}]}
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\@aws-amplify\core\lib-esm\Logger\ConsoleLogger.js:138:12 in prototype._log
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:146334:21 in warn
at node_modules\@aws-amplify\datastore\lib-esm\sync\processors\subscription.js:357:87 in queryObservable.map.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\zen-observable\lib\Observable.js:329:17 in _this2.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\PubSub.js:180:37 in observable.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\Providers\AWSAppSyncRealTimeProvider.js:507:12 in prototype._handleIncomingSubscriptionMessage
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\WebSocket\WebSocket.js:231:8 in _eventEmitter.addListener$argument_1
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
[WARN] 37:23.896 DataStore - subscriptionError, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field '_version' in type 'DbConversion' is undefined @ 'onCreateDbConversion/_version'"},{"message":"Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'DbConversion' is undefined @ 'onCreateDbConversion/_lastChangedAt'"},{"message":"Validation error of type FieldUndefined: Field '_deleted' in type 'DbConversion' is undefined @ 'onCreateDbConversion/_deleted'"}]}
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\@aws-amplify\core\lib-esm\Logger\ConsoleLogger.js:138:12 in prototype._log
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:146334:21 in warn
at node_modules\@aws-amplify\datastore\lib-esm\sync\processors\subscription.js:357:87 in queryObservable.map.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\zen-observable\lib\Observable.js:329:17 in _this2.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\PubSub.js:180:37 in observable.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\Providers\AWSAppSyncRealTimeProvider.js:507:12 in prototype._handleIncomingSubscriptionMessage
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\WebSocket\WebSocket.js:231:8 in _eventEmitter.addListener$argument_1
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
[WARN] 37:23.967 DataStore - subscriptionError, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field '_version' in type 'Capture' is undefined @ 'onDeleteCapture/_version'"},{"message":"Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'Capture' is undefined @ 'onDeleteCapture/_lastChangedAt'"},{"message":"Validation error of type FieldUndefined: Field '_deleted' in type 'Capture' is undefined @ 'onDeleteCapture/_deleted'"}]}
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\@aws-amplify\core\lib-esm\Logger\ConsoleLogger.js:138:12 in prototype._log
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:146334:21 in warn
at node_modules\@aws-amplify\datastore\lib-esm\sync\processors\subscription.js:357:87 in queryObservable.map.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\zen-observable\lib\Observable.js:329:17 in _this2.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\PubSub.js:180:37 in observable.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\Providers\AWSAppSyncRealTimeProvider.js:507:12 in prototype._handleIncomingSubscriptionMessage
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\WebSocket\WebSocket.js:231:8 in _eventEmitter.addListener$argument_1
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
[WARN] 37:24.77 DataStore - subscriptionError, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field '_version' in type 'DbConversion' is undefined @ 'onDeleteDbConversion/_version'"},{"message":"Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'DbConversion' is undefined @ 'onDeleteDbConversion/_lastChangedAt'"},{"message":"Validation error of type FieldUndefined: Field '_deleted' in type 'DbConversion' is undefined @ 'onDeleteDbConversion/_deleted'"}]}
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\@aws-amplify\core\lib-esm\Logger\ConsoleLogger.js:138:12 in prototype._log
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:146334:21 in warn
at node_modules\@aws-amplify\datastore\lib-esm\sync\processors\subscription.js:357:87 in queryObservable.map.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\zen-observable\lib\Observable.js:329:17 in _this2.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\PubSub.js:180:37 in observable.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\Providers\AWSAppSyncRealTimeProvider.js:507:12 in prototype._handleIncomingSubscriptionMessage
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\WebSocket\WebSocket.js:231:8 in _eventEmitter.addListener$argument_1
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
[WARN] 37:24.155 DataStore - subscriptionError, Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field '_version' in type 'DbConversion' is undefined @ 'onUpdateDbConversion/_version'"},{"message":"Validation error of type FieldUndefined: Field '_lastChangedAt' in type 'DbConversion' is undefined @ 'onUpdateDbConversion/_lastChangedAt'"},{"message":"Validation error of type FieldUndefined: Field '_deleted' in type 'DbConversion' is undefined @ 'onUpdateDbConversion/_deleted'"}]}
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\@aws-amplify\core\lib-esm\Logger\ConsoleLogger.js:138:12 in prototype._log
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:146334:21 in warn
at node_modules\@aws-amplify\datastore\lib-esm\sync\processors\subscription.js:357:87 in queryObservable.map.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\zen-observable\lib\Observable.js:329:17 in _this2.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\PubSub.js:180:37 in observable.subscribe$argument_0.error
at node_modules\zen-observable\lib\Observable.js:139:8 in notifySubscription
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:150453:22 in onNotify
at node_modules\zen-observable\lib\Observable.js:239:11 in error
at node_modules\@aws-amplify\pubsub\lib-esm\Providers\AWSAppSyncRealTimeProvider.js:507:12 in prototype._handleIncomingSubscriptionMessage
at node_modules\event-target-shim\dist\event-target-shim.js:818:20 in EventTarget.prototype.dispatchEvent
at node_modules\react-native\Libraries\WebSocket\WebSocket.js:231:8 in _eventEmitter.addListener$argument_1
at node_modules\react-native\Libraries\vendor\emitter\EventEmitter.js:189:10 in emit
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:416:4 in __callFunction
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:109:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:108:4 in callFunctionReturnFlushedQueue
Setting a timer for a long period of time, i.e. multiple minutes, is a performance and correctness issue on Android as it keeps the timer module awake, and timers can only be called when the app is in the foreground. See https://github.com/facebook/react-native/issues/12981 for more info.
(Saw setTimeout with duration 102478.61620927726ms)
at node_modules\react-native\Libraries\LogBox\LogBox.js:117:10 in registerWarning
at node_modules\react-native\Libraries\LogBox\LogBox.js:63:8 in warnImpl
at node_modules\react-native\Libraries\LogBox\LogBox.js:36:4 in console.warn
at node_modules\expo\build\environment\react-native-logs.fx.js:18:4 in warn
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:226:6 in setTimeout
at node_modules\@aws-amplify\core\lib-esm\Util\Retry.js:116:45 in __generator$argument_1
at node_modules\react-native\node_modules\promise\setimmediate\core.js:45:6 in tryCallTwo
at node_modules\react-native\node_modules\promise\setimmediate\core.js:200:22 in doResolve
at node_modules\react-native\node_modules\promise\setimmediate\core.js:66:11 in Promise
at node_modules\@aws-amplify\core\lib-esm\Util\Retry.js:115:40 in __generator$argument_1
at http://192.168.0.105:19000/node_modules%5Cexpo%5CAppEntry.bundle?platform=android&dev=true&hot=false&minify=false:147977:26 in step
at node_modules\tslib\tslib.js:122:34 in <anonymous>
at node_modules\tslib\tslib.js:113:43 in rejected
at node_modules\react-native\node_modules\promise\setimmediate\core.js:37:13 in tryCallOne
at node_modules\react-native\node_modules\promise\setimmediate\core.js:123:24 in setImmediate$argument_0
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:130:14 in _callTimer
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:181:14 in _callImmediatesPass
at node_modules\react-native\Libraries\Core\Timers\JSTimers.js:441:30 in callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:387:6 in __callImmediates
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:135:6 in __guard$argument_0
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:364:10 in __guard
at node_modules\react-native\Libraries\BatchedBridge\MessageQueue.js:134:4 in flushedQueue