You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m encountering an error when attempting to define a custom identifier for my model in Amplify’s data schema. Despite using the recommended syntax, the error persists. Below are the details of the setup and the error message.
Expected behavior
The custom identifier customId should be accepted as the primary identifier for the Shop model without type conflicts.
// Put your logs below this line
Type error: Type '"customId"' is not assignable to type '"items"'.
13 | items: a.ref('Items'),
14 | content: a.string(),
> 15 | }).identifier(['customId']) // Only for models
| ^
16 | .authorization((allow) => [allow.guest()]),
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
The text was updated successfully, but these errors were encountered:
MATTiVOLTARii
changed the title
Type Error with Custom Identifier in Amplify Data Model Schema - .identifier is not assignable to type
Type Error with Custom Identifier in Amplify Data Model Schema - .identifier is not assignable to customType
Nov 11, 2024
MATTiVOLTARii
changed the title
Type Error with Custom Identifier in Amplify Data Model Schema - .identifier is not assignable to customType
Type Error with Custom Identifier in Amplify Data Model Schema - .identifier is not assignable to referenced customType
Nov 11, 2024
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.
Before opening, please confirm:
JavaScript Framework
Next.js
Amplify APIs
DataStore
Amplify Version
v6
Amplify Categories
No response
Backend
Amplify Gen 2
Environment information
Describe the bug
I’m encountering an error when attempting to define a custom identifier for my model in Amplify’s data schema. Despite using the recommended syntax, the error persists. Below are the details of the setup and the error message.
Expected behavior
The custom identifier customId should be accepted as the primary identifier for the Shop model without type conflicts.
Reproduction steps
Shop: a.model({
customId: a.id().required(),
items: a.ref('Items'),
content: a.string(),
})
.identifier(['customId'])
Code Snippet
import { type ClientSchema, a, defineData } from '@aws-amplify/backend';
const schema = a.schema({
Items: a.customType({
name: a.string(),
price: a.string(),
}),
Shop: a.model({
customId: a.id().required(),
items: a.ref('Items'),
content: a.string(),
})
.identifier(['customId'])
.authorization((allow) => [allow.guest()]),
});
export type Schema = ClientSchema;
export const data = defineData({
schema,
authorizationModes: {
defaultAuthorizationMode: "userPool",
},
});
Log output
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
The text was updated successfully, but these errors were encountered: