diff --git a/packages/amplify-graphql-schema-test-library/src/index.ts b/packages/amplify-graphql-schema-test-library/src/index.ts index 2c5fbf1517..27fac718db 100644 --- a/packages/amplify-graphql-schema-test-library/src/index.ts +++ b/packages/amplify-graphql-schema-test-library/src/index.ts @@ -468,5 +468,51 @@ export const schemas: { [key: string]: TransformerSchema } = { } `, }, + 'references-on-hasOne-and-hasMany': { + description: '@hasOne and @hasMany using references', + transformerVersion: TransformerVersion.v2, + supportedPlatforms: TransformerPlatform.all, + sdl: ` + type Primary @model { + id: ID! @primaryKey + relatedMany: [RelatedMany] @hasMany(references: "primaryId") + relatedOne: RelatedOne @hasOne(references: "primaryId") + } + + type RelatedMany @model { + id: ID! @primaryKey + primaryId: ID! + primary: Primary @belongsTo(references: "primaryId") + } + + type RelatedOne @model { + id: ID! @primaryKey + primaryId: ID! + primary: Primary @belongsTo(references: "primaryId") + } + `, + }, + 'references-with-sort-key': { + description: '@hasMany using references and @primaryKey using sortKeyFields', + transformerVersion: TransformerVersion.v2, + supportedPlatforms: TransformerPlatform.all, + sdl: ` + type Primary @model { + tenantId: ID! @primaryKey(sortKeyFields: ["instanceId", "recordId"]) + instanceId: ID! + recordId: ID! + content: String + related: [Related!] @hasMany(references: ["primaryTenantId", "primaryInstanceId", "primaryRecordId"]) + } + + type Related @model { + content: String + primaryTenantId: ID! + primaryInstanceId: ID! + primaryRecordId: ID! + primary: Primary @belongsTo(references: ["primaryTenantId", "primaryInstanceId", "primaryRecordId"]) + } + `, + }, }; // No-op change to trigger publish