I want to implement this GraphQL code below with Flutter using aws Amplify and when i push it it to the repository by it will push it perfectly but when i but when i pull it, it shows this error:
A 'belongsTo' field should match to a corresponding 'hasMany' or 'hasOne' field Error: A 'belongsTo' field should match to a corresponding 'hasMany' or 'hasOne' field at Object.processBelongsToConnection (/snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/utils/process-belongs-to.js:23:15) at Object.processConnectionsV2 (/snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/utils/process-connections-v2.js:97:45) at /snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/visitors/appsync-visitor.js:488:65 at Array.forEach (<anonymous>) at /snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/visitors/appsync-visitor.js:487:26 at Array.forEach (<anonymous>) at AppSyncModelDartVisitor.processConnectionDirectivesV2 (/snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/visitors/appsync-visitor.js:486:38) at AppSyncModelDartVisitor.processDirectives (/snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/visitors/appsync-visitor.js:119:18) at AppSyncModelDartVisitor.generate (/snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/visitors/appsync-dart-visitor.js:26:14) at Object.<anonymous> (/snapshot/repo/build/node_modules/@aws-amplify/appsync-modelgen-plugin/lib/plugin.js:51:24) at Object.executePlugin (/snapshot/repo/build/node_modules/@graphql-codegen/core/dist/commonjs/execute-plugin.js:32:41) at /snapshot/repo/build/node_modules/@graphql-codegen/core/dist/commonjs/codegen.js:58:47 at Array.map (<anonymous>) at Object.codegen (/snapshot/repo/build/node_modules/@graphql-codegen/core/dist/commonjs/codegen.js:48:49) at /snapshot/repo/build/node_modules/amplify-codegen/src/commands/models.js:133:23 at Array.map (<anonymous>) at generateModels (/snapshot/repo/build/node_modules/amplify-codegen/src/commands/models.js:132:46) at async postPullCodegen (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/amplify-service-helper.js:60:9) at async pullBackend (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/pull-backend.js:32:5) at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/commands/pull.js:52:17) at async Object.executeAmplifyCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:292:9) at async executePluginModuleCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:142:5) at async executeCommand (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/execution-manager.js:40:9) at async Object.run (/snapshot/repo/build/node_modules/@aws-amplify/cli-internal/lib/index.js:165:13)
it pushes with no error and i watched the tables in side the amplify studio it was perfect but i want to pull it to create the class models for me, for next use. cause without models there is nothing i could deal with
and this is my graphql code:
type Users @model @auth(rules: [{allow: public}]) {
userId: ID!
email: AWSEmail
phone: AWSPhone
bio: String
social_links: AWSJSON
profile_image: String
followUsersFollower: [FollowUsers] @hasMany(indexName: "byUser_followUsersFollower", fields: ["userId"])
followUsersReciever: [FollowUsers] @hasMany(indexName: "byUser_followUsersReciever", fields: ["userId"])
followClubs: [FollowClubs] @hasMany(indexName: "byUser_followClubs", fields: ["userId"])
clubs: [Clubs] @hasMany(indexName: "byUser_clubs", fields:["userId"])
userTopics: [UserTopics] @hasMany(indexName: "byUser_userTopics", fields:["userId"])
userChatSender: [UserChats] @hasMany(indexName: "byUser_userChatSender", fields:["userId"])
userChatReciever: [UserChats] @hasMany(indexName: "byUser_userChatReciever", fields:["userId"])
participants: [Participants] @hasMany(indexName: "byUser_participants", fields:["userId"])
rooms: [Rooms] @hasMany(indexName: "byUser_rooms", fields:["userId"])
}
type FollowUsers @model @auth(rules: [{allow: public}]) {
userIdFollower: ID! @index(name: "byUser_followUsersFollower")
userIdFollowed: ID! @index(name: "byUser_followUsersReciever")
userIdFollower2: Users @belongsTo(fields: ["userIdFollower"])
userIdFollowed2: Users @belongsTo(fields: ["userIdFollowed"])
}
type Topics @model @auth(rules: [{allow: public}]) {
topicId: ID!
name: String!
description: String
clubs: [Clubs]@hasMany(indexName: "byTopic_clubs", fields: ["topicId"])
userTopics: [UserTopics] @hasMany(indexName: "byTopic_userTopics", fields: ["topicId"])
}
type Clubs @model @auth(rules: [{allow: public}]){
clubId: ID!
name: String!
userIdFounder: ID! @index(name: "byUser_clubs")
topicId: ID! @index(name: "byTopic_clubs")
topicId2: Topics @belongsTo(fields: ["topicId"])
userIdFounder2: Users @belongsTo(fields: ["userIdFounder"])
follow: [FollowClubs] @hasMany(indexName: "byClub_follow", fields: ["clubId"])
}
type FollowClubs @model @auth(rules: [{allow: public}]){
clubId: ID! @index(name: "byClub_follow")
userId: ID! @index(name: "byUser_followClubs")
clubId2: Clubs @belongsTo(fields: ["clubId"])
userId2: Users @belongsTo(fields: ["userId"])
}
type UserTopics @model @auth(rules: [{allow: public}]){
userId: ID! @index(name: "byUser_userTopics")
topicId: ID! @index(name: "byTopic_userTopics")
userId2: Users @belongsTo(fields: ["userId"])
topicId2: Topics @belongsTo(fields: ["topicId"])
}
type UserChats @model @auth(rules: [{allow: public}]){
userChatId: ID!
content: String
userIdSender: ID! @index(name: "byUser_userChatSender")
userIdReciever: ID! @index(name: "byUser_userChatReciever")
userIdSender2: Users @belongsTo(fields: ["userIdSender"])
userIdReciever2: Users @belongsTo(fields: ["userIdReciever"])
}
type Rooms @model @auth(rules: [{allow: public}]){
roomId: ID!
name: String!
description: String
dateTime: AWSDateTime
participants: [Participants] @hasMany(indexName: "byRoom_participants", fields: ["roomId"])
founderId: ID! @index(name: "byUser_rooms")
founderId2: Users @belongsTo(fields: ["founderId"])
}
type Participants @model @auth(rules: [{allow: public}]){
participantsId: ID!
role: String
joinDate: AWSDateTime
peeringId: ID! # this must be an auto generated id
userId: ID! @index(name: "byUser_participants")
roomId: ID! @index(name: "byRoom_participants")
userId2: Users @belongsTo(fields: ["userId"])
roomId2: Rooms @belongsTo(fields: ["roomId"])
participantIdSender: [RoomChats] @hasMany(indexName: "byParticipants_participantIdSender", fields: ["participantsId"])
}
type RoomChats @model @auth(rules: [{allow: public}]){
roomChatId: ID!
content: String
participantIdSender: ID! @index(name: "byParticipants_participantIdSender")
participantIdSender2: Participants @belongsTo(fields: ["participantIdSender"])
}