天天看點

amplify踩坑之旅

1,datastore does not support 1 to 1 connection with both sides of connection as optional field: album.attraction

there was an error pushing the api resource

error: datastore does not support 1 to 1 connection with both sides of connection as optional field: album.attraction

解決:attraction: attraction! @connection(name: "attractionalbums", fields:["attractionid"], sortfield: "createdat") #加個!号

2, one or more parameter values were invalid: index keyschema does not have a range key for index: bycourse

設定表關系一對多

解決:将二級索引bycourse删除,從表設定主索引@key(fields: ["courseid","sort"])

3,attempting to edit the key schema of the attractiontable table in the attraction stack.

cause: adding a primary @key directive to an existing @model.

how to fix: remove the @key directive or provide a name e.g @key(name: "bystatus", fields: ["status"]).

解決:繼上面2,設定主索引的主鍵為id時報的錯,改為courseid

4,amplify following resources failed     或amplify missing required key 'apiid' in params 。。。。。

終極處理:

1,amplify delete

2,npm cache clean -f

3,amplify configure

4,amplify init

接下來一個個重新add ,push update

4,這個最難搞

attempting to edit the global secondary index byattraction on the albumtable table in the album stack.

cause: the key schema of a global secondary index cannot be changed after being deployed.

how to fix: if using @key, first add a new @key, run `amplify push`, and then remove the old @key. if using @connection,

first remove the @connection, run `amplify push`, and then add the new @connection with the new configuration.

解決:remove重新add,push

5,設定資料表排序必須通過@key建立二級索引queryfield=另外建立一個查詢語句  #@key(name: "sort", fields: ["partition","level"], queryfield: "sorybylevel")

6,key設定沖突有時不能通gql-compile檢查出,要push才知道

7,push到一半取消會有風險,導緻資料庫不能重建

8,當項目檔案移到新的裝置,ampflfy push時會報以下錯誤

- fetching updates to backend environment: dev from the cloud.could not initialize 'dev': the "path" argument must be of

type string. received an instance of error

解決:重新  amplify configure project

9,當push失敗後,再push會報找不到檔案error: enoent: no such file or directory, stat 'c:\www\fcpointp\amplify\#current-cloud-backend\function\fcpointp5199be52

解決:

i did the following and it resolved my issues.

follow the instructions here and call amplify hosting add.

then move the api and auth folders and their content from the backend folder to the #current-cloud-backend folder.

then run amplify push.

但我是用  amplify env checkout devone  再 push 解決的  ##devone   是環境名

10,經過不懈努力,解決lambda無法更新資料庫問題,對比demo發現建立資料庫時缺少 以下内容

@auth(rules: [{ allow: owner }##原有,

{ allow: private, provider: iam, operations: [ read, update ] }##缺少部分])

11,dynomadb 導資料流程

利用data pipeline 服務

先從dynomadb導入出一條假資料到s3,然後把要導的資料填入導出來的模闆檔案中,再從s3中選擇前面導出資料的檔案夾,而不是選擇模闆檔案。

12,vue打包後bootstrap的樣式不生效的原因是demo中引入了tailwind.css,應将其與

一并删除

 13.appsync使用transactwriteitems事務操作,因自定義解析器需要操作多個表,建立資源同時必須建立角色和資料源,利用cloudformation建立角色時總是報錯,是因為教程中customresources.json的寫法還是舊式:

 14.在我自定義的resolver中$util.autoid() 不生效,報variable 'point' has coerced null value for nonnull type 'id!