Skip to content

Commit

Permalink
test: add references test schemas to library (#2442)
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch authored Apr 10, 2024
1 parent 0c45218 commit f1bc549
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions packages/amplify-graphql-schema-test-library/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f1bc549

Please sign in to comment.