Closed MATTiVOLTARii closed 3 days ago
I don't know exactly why but with "as any" it seems to work:
Items: a.customType({
name: a.string(),
price: a.string(),
}),
Shop: a.model({
customId: a.id().required() as any,
items: a.ref('Items'),
content: a.string(),
})
.identifier(['customId'])
.authorization((allow) => [allow.guest()]),
Hi @MATTiVOLTARii 👋 thanks for raising this issue.
can you please share the dependencies listed in your package.json file?
also, curious what version of @aws-amplify/data-schema
you have installed. you can check this by running:
npm list @aws-amplify/data-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!
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