Closed outraday closed 2 weeks ago
For everybody else having this error. It is not a bug but a missing package.
The autogenerated .sql file has eslint disabled which did not show me that I missed @aws-amplify/data-schema
package. Installed it as dev dependency and then it worked.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
GraphQL API, DataStore
Amplify Version
v6
Amplify Categories
api
Backend
Amplify Gen 2 (Preview)
Environment information
Describe the bug
When adding an external postgresql schema with
combine
I get an error in functionexcludeDisabledOps
inclientUtils.ts
file:TypeError: coarseToFineDict[key] is not iterable (cannot read property undefined)
I digged into it and found out that models that are generated after configuring the external database have an attribute of type
model
where the only key in the properties object istimestamp
. The function iterates over the keys and tries to spread outcoarseToFineDict[key]
. The only keys in this dict arequeries, mutations, subscriptions
. No keytimestamp
exists, therefore the value is undefined and trying to spread it gives the error. On regular schema models the properties object is empty and no error occurs.Expected behavior
The external database schema from postgres can be genereated without any errors and then be combined with the regular datastore schema.
Reproduction steps
Following the steps from the guide: https://docs.amplify.aws/react/build-a-backend/data/connect-to-existing-data-sources/connect-postgres-mysql-database/#step-2---generate-typescript-representation-of-your-database-schema
Typescript representation of the database schema:
npx ampx generate schema-from-database --connection-uri-secret SQL_CONNECTION_STRING --out amplify/data/schema.sql.ts
Combining the schemas with the
combine
methodRun
ampx sandbox
Start the application
Code Snippet
The schema.sql.file
Combining the schemas:
Log output
TypeError: coarseToFineDict[key] is not iterable (cannot read property undefined) at excludeDisabledOps (clientUtils.ts:47:29) at generateModelsProperty (generateModelsProperty.ts:17:33) at addSchemaToClient (addSchemaToClient.ts:6:21) at generateClient (generateClient.ts:35:9) at generateClient2 (API.ts:10:12) at amplify-client.ts:10:30
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response