Working with amplify datastore and edited schema.graphql as following and when I enter "amplify codegen models" I get this error " Error: Expected scalar and got User " However the code was generated successfully. How would I be able to fix this error?
type User
@model
@key(name: "ByEmail", fields: ["email"], queryField: "userByEmail")
@auth(rules: [{ allow: owner }]) {
id: ID!
email: String!
gender: String!
birthdate: String!
faceImage: String
favoriteAvatar: [Avatar] @connection(fields: ["avatarId"])
totalVideoTransform: Int
registerAt: AWSDateTime!
}
type Avatar
@model
@key(name: "ByAvatrId", fields: ["avatarId"], queryField: "avatarByAvatarId")
@auth(rules: [{ allow: owner, ownerField: "favoriteUser", operations: [create, update, read] }]) {
id: ID!
avatarId: String!
gender: String!
favoriteUser: [User] @connection(fields: ["email"])
totalVideoTransform: Int
}
type UserLoginLog
@model
@key(name: "ByUser", fields: ["user"], queryField: "userLoginLogByUser")
@auth(rules: [{ allow: owner, operations: [create] }]) {
id: ID!
user: User @connection(fields: ["email"])
loginAt: AWSDateTime!
}
type VideoTransformLog
@model
@key(name: "ByUser", fields: ["user"], queryField: "videoTransformLogByUser")
@auth(rules: [{ allow: owner, operations: [create] }]) {
id: ID!
user: User @connection(fields: ["email"])
avatar: Avatar @connection(fields: ["avatarId"])
videoTransformAt: AWSDateTime!
}
In your types "UserLoginLog" and "VideoTransformLog", remove "user" from the @key(... fields). So don't place names that correspond to a type in fields[].
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.