From f1bc5496689424d4035411082d9e0462c6a220ba Mon Sep 17 00:00:00 2001 From: Dane Pilcher Date: Wed, 10 Apr 2024 12:46:48 -0600 Subject: [PATCH] test: add references test schemas to library (#2442) --- .../src/index.ts | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) 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