Open
Description
Description
I have two parent / child tables, and the parent table has custom primary key:
type Book @model @auth(rules: [{ allow: private, ownerField: "pOwner" }]) {
id: ID! @primaryKey(sortKeyFields: ["title", "description"])
title: String!
description: String!
writers: [Writer] @hasMany(indexName: "byBook", fields: ["id"])
pOwner: String!
}
type Writer @model {
id: ID!
fname: String!
lname: String!
bookID: ID! @index(name: "byBook", sortKeyFields: ["id"])
book: Book! @belongsTo(fields: ["bookID"])
pOwner: String!
}
When I add the same @auth to the child, I get the following error on attempt to generate the model with 'amplify codegen models':
InvalidDirectiveError: Invalid @belongsTo on Writer:book. Provided fields do not match the size of primary key(s) for Book
Below are the models that cause this error:
type Book @model @auth(rules: [{ allow: private, ownerField: "pOwner" }]) {
id: ID! @primaryKey(sortKeyFields: ["title", "description"])
title: String!
description: String!
writers: [Writer] @hasMany(indexName: "byBook", fields: ["id"])
pOwner: String!
}
type Writer @model @auth(rules: [{ allow: private, ownerField: "pOwner" }]) {
id: ID!
fname: String!
lname: String!
bookID: ID! @index(name: "byBook", sortKeyFields: ["id"])
book: Book! @belongsTo(fields: ["bookID"])
pOwner: String!
}
Categories
- Analytics
- API (REST)
- API (GraphQL)
- Auth
- Authenticator
- DataStore
- Notifications (Push)
- Storage
Steps to Reproduce
No response
Screenshots
No response
Platforms
- iOS
- Android
- Web
- macOS
- Windows
- Linux
Flutter Version
3.13.5
Amplify Flutter Version
1.5.0
Deployment Method
Amplify CLI
Schema
No response