amplify-js: DataStore - Sync error, subscription failed Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field 'blogDemoPostsId' in type 'PostDemo' is undefined @ 'onCreatePostDemo/blogDemoPostsId'"}]}
Describe the bug When I try to query/observe and save an object into the datastore I get following error:
[WARN] 55:26.322 DataStore - Sync error, subscription failed Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field 'blogDemoPostsId' in type 'PostDemo' is undefined @ 'onCreatePostDemo/blogDemoPostsId'"}]}
- node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
* [native code]:null in warn
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:124726:12 in <unknown>
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:124759:22 in <unknown>
- node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js:638:35 in sync.start.subscribe$argument_0.error
- node_modules/zen-observable/lib/Observable.js:139:8 in notifySubscription
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:129431:23 in onNotify
- node_modules/zen-observable/lib/Observable.js:239:11 in error
- node_modules/@aws-amplify/datastore/lib-esm/sync/index.js:141:56 in __generator$argument_1
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:126332:27 in step
- node_modules/tslib/tslib.js:120:34 in <anonymous>
- node_modules/tslib/tslib.js:111:43 in rejected
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
I get this error when I interact with DataStore with this snippet:
const testDataStore = (username: string) => {
DataStore.query(BlogDemo)
.then((data) => {
console.log(data);
DataStore.observe(BlogDemo).subscribe((event) => {
console.log("=======SUB======");
console.log(event);
});
let blog = new BlogDemo({
name: "testBlog",
posts: [],
editors: [username],
});
console.log("save blog post");
DataStore.save(blog);
})
.catch((err) => console.log(err));
};
To Reproduce Steps to reproduce the behavior:
- Initialised a new project with Expo SDK 37.0.0 and Amplify Cli 4.18.0 and aws-amplify 3.0.7 and @aws-amplify/pubsub 3.0.7.
- added api, and auth.
- used provided schema for Blog, Posts and Comment.
- amplify codegen I get the error (argument must be a string)
- fixed the model and pushed changes with amplify push
- ran amplify codegen models that gives me an error saying that I can’t use keyName in connection.
- removed all connection and keys from the schema obtaining the following schema:
type BlogDemo @model @auth(rules: [{ allow: owner, ownerField: "editors" }]) {
id: ID!
name: String!
posts: [PostDemo] @connection
editors: [String]!
}
type PostDemo @model @auth(rules: [{ allow: owner, ownerField: "editors" }]) {
id: ID!
title: String!
blog: BlogDemo @connection
comments: [CommentDemo] @connection
editors: [String]!
}
type CommentDemo
@model
@auth(rules: [{ allow: owner, ownerField: "editors" }]) {
id: ID!
post: PostDemo @connection
content: String!
editors: [String]!
}
I added owners attributes as an Array su support multiple oweners.
Expected behavior DataStore works without any error. And I can save/query and subscribe to Models.
Environment
npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages
System:
OS: macOS 10.15.4
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Memory: 519.36 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 13.12.0 - /usr/local/bin/node
npm: 6.14.4 - /usr/local/bin/npm
Browsers:
Chrome: 81.0.4044.92
Firefox: 75.0
Safari: 13.1
npmPackages:
@aws-amplify/pubsub: ^3.0.7 => 3.0.7
@babel/core: ^7.8.6 => 7.9.0
@react-native-community/netinfo: 5.5.1 => 5.5.1
@types/react: ~16.9.23 => 16.9.34
@types/react-native: ~0.61.17 => 0.61.23
aws-amplify: ^3.0.7 => 3.0.7
babel-preset-expo: ~8.1.0 => 8.1.0
expo: ~37.0.3 => 37.0.7
react: ~16.9.0 => 16.9.0
react-dom: ~16.9.0 => 16.9.0
react-native: https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz => 0.61.4
react-native-screens: ~2.2.0 => 2.2.0
react-native-web: ~0.11.7 => 0.11.7
typescript: ~3.8.3 => 3.8.3
npmGlobalPackages:
@aws-amplify/cli: 4.18.0
expo-cli: 3.17.24
npm: 6.14.4
react-native-cli: 2.0.1
Smartphone (please complete the following information):
- Device: iPhone8 - Simulator
- OS: iOS13.4
- Client: Expo 37
Sample Log
Array []
save blog post
[INFO] 05:38.220 Reachability - subscribing to reachability
[INFO] 05:38.233 Reachability - Notifying initial reachability state null
=======SUB======
Object {
"condition": undefined,
"element": BlogDemo {
"_deleted": undefined,
"_lastChangedAt": undefined,
"_version": undefined,
"editors": Array [
"5c95f0eb-4662-4019-94e7-5ae073fed854",
],
"id": "ab07dcf1-9c14-44cf-a142-8c0115e700e3",
"name": "testBlog",
"posts": Array [],
},
"model": [Function BlogDemo],
"opType": "INSERT",
}
[INFO] 05:40.224 Reachability - Notifying reachability change true
[WARN] 05:40.894 DataStore - Sync error, subscription failed Connection failed: {"errors":[{"message":"Validation error of type FieldUndefined: Field 'blogDemoPostsId' in type 'PostDemo' is undefined @ 'onCreatePostDemo/blogDemoPostsId'"}]}
- node_modules/expo/build/environment/muteWarnings.fx.js:18:23 in warn
* [native code]:null in warn
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:124726:12 in <unknown>
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:124759:22 in <unknown>
- node_modules/@aws-amplify/datastore/lib-esm/datastore/datastore.js:638:35 in sync.start.subscribe$argument_0.error
- node_modules/zen-observable/lib/Observable.js:139:8 in notifySubscription
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:129431:23 in onNotify
- node_modules/zen-observable/lib/Observable.js:239:11 in error
- node_modules/@aws-amplify/datastore/lib-esm/sync/index.js:141:56 in __generator$argument_1
* http://127.0.0.1:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:126332:27 in step
- node_modules/tslib/tslib.js:120:34 in <anonymous>
- node_modules/tslib/tslib.js:111:43 in rejected
- node_modules/promise/setimmediate/core.js:37:14 in tryCallOne
- node_modules/promise/setimmediate/core.js:123:25 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:146:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:194:17 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:458:30 in callImmediates
* [native code]:null in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:407:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:143:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:384:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:142:17 in __guard$argument_0
* [native code]:null in flushedQueue
* [native code]:null in callFunctionReturnFlushedQueue
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (2 by maintainers)
I confirm that with latest version everything works.