【发布时间】:2022-11-01 16:29:49
【问题描述】:
我正在开发一个使用 AppSync 和来自 aws 的 graphql 的应用程序,但是每当我运行以下代码行 DataStore.start() 时,都会发生以下错误:
[错误] 数据存储 - 架构未初始化。 DataStore 将无法按预期运行。如果您安装了多个版本的 DataStore,则可能会发生这种情况。请看https://docs.amplify.aws/lib/troubleshooting/upgrading/q/platform/js/#check-for-duplicate-versions
我不知道还能做什么。我什至从 0 开始了一个应用程序,并且发生了同样的问题。我已经删除了 node_modules 文件夹并重新安装了所有内容,但它不会而且我想不出一种方法来映射可能的错误。下面是代码和包。
import Amplify, { API, Auth, DataStore, Hub, Storage } from 'aws-amplify';
import awsmobile from './src/aws-exports';
import awsapigateway from './src/aws-api-gateway';
Amplify.Logger.LOG_LEVEL = 'DEBUG';
Amplify.configure(awsmobile);
API.configure(awsapigateway);
DataStore.start()
.then(() => console.log('DataStore started'))
.catch(e => console.log('Error init datastore: ', e))
.finally(() => console.log('DataStore finally'));
包.json
"dependencies": {
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7",
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
"@babel/plugin-syntax-flow": "^7.14.5",
"@babel/plugin-transform-react-jsx": "^7.14.9",
"@react-native-async-storage/async-storage": "^1.17.7",
"@react-native-community/geolocation": "^2.0.2",
"@react-native-community/netinfo": "^9.3.0",
"@react-native-picker/picker": "^2.4.0",
"@react-navigation/bottom-tabs": "^6.2.0",
"@react-navigation/native": "^6.0.8",
"@react-navigation/stack": "^6.1.1",
"amazon-cognito-identity-js": "^5.2.8",
"aws-amplify": "^4.3.26",
"graphql": "16.5.0",
"graphql-tools": "^8.3.0",
"moment": "^2.29.1",
"prettier": "^2.6.0",
"prop-types": "^15.8.1",
"radio-buttons-react-native": "^1.0.4",
"react": "^17.0.2",
"react-native": "^0.68.2",
"react-native-android-location-services-dialog-box": "^2.8.2",
"react-native-bootsplash": "^4.1.4",
"react-native-debugger": "^1.1.0",
"react-native-elements": "^3.4.2",
"react-native-fs": "^2.19.0",
"react-native-gesture-handler": "2.5.0",
"react-native-get-random-values": "^1.7.2",
"react-native-image-pan-zoom": "^2.1.12",
"react-native-linear-gradient": "^2.5.6",
"react-native-loading-spinner-overlay": "^3.0.0",
"react-native-permissions": "^3.3.1",
"react-native-pressable-opacity": "^1.0.8",
"react-native-reanimated": "^2.8.0",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": ">= 3.0.0",
"react-native-sqlite-storage": "^6.0.1",
"react-native-static-safe-area-insets": "^2.1.1",
"react-native-vector-icons": "^9.1.0",
"react-native-vision-camera": "^2.13.3",
"typescript": "^4.6.2",
"uuid": "^8.3.2",
"vision-camera-code-scanner": "^0.2.0"
},
"devDependencies": {
"@babel/core": "7.18.6",
"@babel/preset-env": "7.18.6",
"@babel/runtime": "^7.17.8",
"@react-native-community/eslint-config": "^2.0.0",
"@react-native-community/eslint-plugin": "^1.1.0",
"babel-eslint": "^10.1.0",
"babel-jest": "^28.1.1",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.25.4",
"eslint-plugin-jsx-a11y": "^6.5.1",
"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.3.0",
"ini": "^1.3.5",
"inquirer": "^6.5.1",
"jest": "^28.1.1",
"metro-react-native-babel-preset": "^0.71.2",
"react-test-renderer": "^17.0.2"
},
schema.graphql:"
type Subpoena @model @auth(rules: [{allow: public}]) {
id: id!
status: SyncStatus!
localImageStorage: AWSJSON
}
enum SyncStatus {
PENDING
DONATE
ERROR
}
【问题讨论】:
-
您是否尝试过问题链接中的命令之一?
-
面对同样的问题,有没有人找到解决方案?
-
就我而言,当我开始运行诸如“DataStore.query(Todo)”之类的查询时,“未初始化的模式”错误消失了。
标签: amazon-web-services react-native aws-amplify aws-appsync datastore