I have the following setup in my schema.graphql:
type TrainingInfo @model @auth(rules: [{allow: public}]) {
id: ID!
title: String!
description: String!
rating: Int
trainingInfoID: [AssigneeList] @connection(keyName: "byTrainingInfo", fields: ["id"])
creator: Users @connection
trainingVideos: [TrainingVideo] @connection(keyName: "byTrainingInfo", fields: ["id"])
groups: [TrainingInfoGroups] @connection(keyName: "byTrainingInfo", fields: ["id"])
}
type Users @model @auth(rules: [{allow: public}]) @key(name: "byCompany", fields: ["companyID"]) {
id: ID!
firstname: String!
lastname: String!
email: AWSEmail
username: String
confirmed: Boolean
companyID: ID
groups: [UsersGroups] @connection(keyName: "byUsers", fields: ["id"])
}
When I add a new TrainingInfo data in the Amplify DB with properly set fields I get the following error on iOS when adding the data:
{"onCreateTrainingInfo":{"id":"96902155-b5d8-4765-a8de-f5692e456989","description":"haha","rating":100,"title":"ADADADADADA","creator":null,"__typename":"TrainingInfo","_version":1,"_deleted":null,"_lastChangedAt":1640897426788}},"errors":[{"message":"Cannot return null for non-nullable type: 'String' within parent 'Users' (/onCreateTrainingInfo/creator/firstname)","path":["onCreateTrainingInfo","creator","firstname"]},{"message":"Cannot return null for non-nullable type: 'String' within parent 'Users' (/onCreateTrainingInfo/creator/lastname)","path":["onCreateTrainingInfo","creator","lastname"]},{"message":"Cannot return null for non-nullable type: 'Int' within parent 'Users' (/onCreateTrainingInfo/creator/_version)","path":["onCreateTrainingInfo","creator","_version"]},{"message":"Cannot return null for non-nullable type: 'AWSTimestamp' within parent 'Users' (/onCreateTrainingInfo/creator/_lastChangedAt)","path":["onCreateTrainingInfo","creator","_lastChangedAt"]}]}}
It seems like only 'creator' field is the problem and it is the only one with hasOne relationship.
When I tried running the same code on Android I got similar error where all creator fields are null while id != null.
I've tried renaming, deleting and adding the field again but I keep getting the same error.
I am using the version 0.2.10 for amplify_flutter and amplify_datastore.