@@ -24,18 +24,6 @@ const createAndGeneratePipelinedTransformerVisitor = (schema: string) => {
2424 return createAndGenerateVisitor ( schema , true ) ;
2525} ;
2626
27- const createGraphQLV2TransformerVisitor = ( schema : string ) => {
28- const ast = parse ( schema ) ;
29- const builtSchema = buildSchemaWithDirectives ( schema ) ;
30- const visitor = new AppSyncModelVisitor (
31- builtSchema ,
32- { directives, target : 'general' , isTimestampFieldsAdded : true , usePipelinedTransformer : true } ,
33- { generate : CodeGenGenerateEnum . code } ,
34- ) ;
35- visit ( ast , { leave : visitor } ) ;
36- return visitor ;
37- }
38-
3927describe ( 'AppSyncModelVisitor' , ( ) => {
4028 it ( 'should support schema with id' , ( ) => {
4129 const schema = /* GraphQL */ `
@@ -912,6 +900,13 @@ describe('AppSyncModelVisitor', () => {
912900
913901 describe . only ( 'Graphql V2 fix tests for multiple has many relations of only one model type' , ( ) => {
914902 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+ }
915910 type Meeting @model {
916911 id: ID! @primaryKey
917912 title: String!
@@ -922,21 +917,9 @@ describe('AppSyncModelVisitor', () => {
922917 id: ID! @primaryKey
923918 meetings: [Registration] @hasMany(indexName: "byAttendee", fields: ["id"])
924919 }
925-
926- type Registration @model {
927- id: ID! @primaryKey
928- meetingId: ID @index(name: "byMeeting", sortKeyFields: ["attendeeId"])
929- meeting: Meeting! @belongsTo(fields: ["meetingId"])
930- attendeeId: ID @index(name: "byAttendee", sortKeyFields: ["meetingId"])
931- attendee: Attendee! @belongsTo(fields: ["attendeeId"])
932- }
933920 ` ;
934- const outputModels : string [ ] = [ 'Meeting' , 'Attendee' , 'Registration' ] ;
935- outputModels . forEach ( model => {
936- it ( `should not throw error when processing ${ model } ` , ( ) => {
937- const visitor = createGraphQLV2TransformerVisitor ( schema ) ;
938- expect ( ( ) => visitor . generate ( ) ) . not . toThrow ( ) ;
939- } ) ;
940- } )
921+ it ( `should not throw error when processing models` , ( ) => {
922+ expect ( ( ) => createAndGeneratePipelinedTransformerVisitor ( schema ) ) . not . toThrow ( ) ;
923+ } ) ;
941924 } )
942925} ) ;
0 commit comments