I am currently experiencing an issue with @belongsTo in connection with @auth when more than one sortKey is inside of the parent element.
The following error comes up when I try to amplify push the schema:
🛑 Invalid @belongsTo on Comments:todo. Provided fields do not match the size of primary key(s) for Todos
Below schema should reproduce the error:
type Todos @model @auth(rules: [{ allow: public }]) {
id: ID!
createdAt: String
number: Int
title: String
description: String
comments: [Comments] @hasMany(indexName: "byComments", fields: ["id"])
baseType: String
@index(
name: "byNumber"
queryField: "todosByNumber"
sortKeyFields: ["number"]
)
@index(
name: "byTitle"
queryField: "todosByTitle"
sortKeyFields: ["title"]
)
@index(
name: "byDescription"
queryField: "todosByDescription"
sortKeyFields: ["description"]
)
}
type Comments @model @auth(rules: [{ allow: public }]) {
id: ID!
todosID: ID! @index(name: "byComments")
todo: Todos @belongsTo(fields: ["todosID"])
createdAt: String
firstName: String
lastName: String
messageID: ID @index(name: "commentsByMessages")
message: Messages @belongsTo(fields: "messageID")
}
type Messages @model @auth(rules: [{ allow: public }]) {
id: ID!
title: String
content: String
comments: [Comments] @hasMany(indexName: "byComments", fields: ["id"])
}
Does anyone have a solution on how to setup @belongsTo and @auth correctly or is this a bug?
Looking forward to your help!🙂