Skip to content

Commit b311aea

Browse files
authored
Merge pull request #353 from aws-amplify/merge-gqlv2-fix-into-master
Release gqlv2-fix branch into master to address native platform issues.
2 parents fdd29ae + 7b4a24d commit b311aea

18 files changed

+10756
-28
lines changed

packages/appsync-modelgen-plugin/src/__tests__/visitors/appsync-visitor.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,4 +897,29 @@ describe('AppSyncModelVisitor', () => {
897897
expect(visitor.models.ModelB.fields[1].directives[0].arguments.indexName).toEqual('byModelB');
898898
});
899899
});
900+
901+
describe('Graphql V2 fix tests for multiple has many relations of only one model type', () => {
902+
const schema = /* GraphQL*/ `
903+
type Registration @model {
904+
id: ID! @primaryKey
905+
meetingId: ID @index(name: "byMeeting", sortKeyFields: ["attendeeId"])
906+
meeting: Meeting! @belongsTo(fields: ["meetingId"])
907+
attendeeId: ID @index(name: "byAttendee", sortKeyFields: ["meetingId"])
908+
attendee: Attendee! @belongsTo(fields: ["attendeeId"])
909+
}
910+
type Meeting @model {
911+
id: ID! @primaryKey
912+
title: String!
913+
attendees: [Registration] @hasMany(indexName: "byMeeting", fields: ["id"])
914+
}
915+
916+
type Attendee @model {
917+
id: ID! @primaryKey
918+
meetings: [Registration] @hasMany(indexName: "byAttendee", fields: ["id"])
919+
}
920+
`;
921+
it(`should not throw error when processing models`, () => {
922+
expect(() => createAndGeneratePipelinedTransformerVisitor(schema)).not.toThrow();
923+
});
924+
})
900925
});

0 commit comments

Comments
 (0)