Closed rnrnstar2 closed 4 months ago
Hey👋 thanks for raising this! I'm going to transfer this over to our API repository for better assistance 🙂
Hi @rnrnstar2, can you please run this command to update your @aws-amplify/data-schema
package?
npm update @aws-amplify/data-schema
Then, try your code again and let us know if the issue is resolved
The error still occurs.
Should I install @aws-amplify/data-schema
by itself rather than as a dependency?
Do you have a reference package.json?
I'm not able to reproduce this issue on the latest versions of the amplify backend packages.
Could also try updating aws-amplify
, though I'm not sure if that will help with types.
Might be best to start clean by deleting node_modules
, package-lock.json
and then reinstalling dependencies.
Also, might help to restart the TypeScript server in your IDE.
My dev dependencies are:
"devDependencies": {
"@aws-amplify/backend": "^1.0.3",
"@aws-amplify/backend-cli": "^1.0.4",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.0.1",
"aws-cdk": "^2.137.0",
"aws-cdk-lib": "^2.137.0",
"constructs": "^10.3.0",
"eslint": "^8",
"eslint-config-next": "14.1.0",
"postcss": "^8",
"tailwindcss": "^3.3.0",
"typescript": "^5.3.3"
}
I deleted node_modules
, cleaned package-lock.json
and installed but it didn't improve anything.
I ran TypeScript: Restart TS Server but it didn't solve the problem.
Is it because I'm using cursor as the editor?
My dev dependencies are:
"devDependencies": {
"@aws-amplify/backend": "^1.0.3",
"@aws-amplify/backend-cli": "^1.0.4",
"@tailwindcss/aspect-ratio": "^0.4.2",
"@tailwindcss/typography": "^0.5.13",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"autoprefixer": "^10.4.19",
"aws-cdk": "^2.144.0",
"aws-cdk-lib": "^2.144.0",
"constructs": "^10.3.0",
"esbuild": "^0.21.4",
"eslint": "^8",
"eslint-config-next": "14",
"postcss": "^8",
"tailwindcss": "^3.4.4",
"tsx": "^4.13.0",
"typescript": "^5.4.5"
}
These are part of package-lock.json. Even if you do a clean install, the 1.0.0 version is still a dependency.
@rnrnstar2 - I tried to reproduce this issue using your schema, the dependencies you've listed, and the Cursor IDE, but have not had any luck.
Looking at your schema, it appears that your mutation is missing the platform
field, which is required in your schema. Here, the following:
await client.models.Category.create({
name: "test",
});
should instead be:
await client.models.Category.create({
name: "test",
platform: "TEST2", // unsure what your enum values are, as they are not listed in the schema
});
When I attempt to exclude the platform
field, I (correctly) receive the following error:
Argument of type '{ name: string; }' is not assignable to parameter of type '{ id?: string | undefined; name: string; platform: string; content?: Nullable<string> | undefined; s3ImgKey?: Nullable<string> | undefined; }'.
Property 'platform' is missing in type '{ name: string; }' but required in type '{ id?: string | undefined; name: string; platform: string; content?: Nullable<string> | undefined; s3ImgKey?: Nullable<string> | undefined; }'.ts(2345)
resource.ts(17, 9): 'platform' is declared here.
Just as a check, have you run npx ampx sandbox
after updating your schema?
Hi 👋 Closing this as we have not heard back from you. If you are still experiencing this issue and in need of assistance, please feel free to comment and provide us with any information previously requested by our team members so we can re-open this issue and be better able to assist you.
Thank you!
@chrisbonifacio
I have the same TS error on the schema when having set identifiers
amplify/data/resource.ts:62:18 - error TS2322: Type 'string' is not assignable to type 'never'.
62 .identifier(["eventID"])
amplify/data/resource.ts:83:18 - error TS2322: Type 'string' is not assignable to type 'never'.
83 .identifier(["profileID"])
amplify/data/resource.ts:96:18 - error TS2322: Type 'string' is not assignable to type 'never'.
96 .identifier(["eventID", "profileID"])
amplify/data/resource.ts:96:29 - error TS2322: Type 'string' is not assignable to type 'never'.
96 .identifier(["eventID", "profileID"])
amplify/data/resource.ts:108:18 - error TS2322: Type 'string' is not assignable to type 'never'.
108 .identifier(["messageID"])
Environment information
Description
Here is the error message.