@aws-amplify/graphql-relational-transformer
Advanced tools
Comparing version 2.3.2 to 2.3.3
@@ -6,2 +6,8 @@ # Change Log | ||
## [2.3.3](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-relational-transformer@2.3.2...@aws-amplify/graphql-relational-transformer@2.3.3) (2023-12-21) | ||
### Bug Fixes | ||
- Fix manyToMany relationships with Amplify managed table strategies ([#2151](https://github.com/aws-amplify/amplify-category-api/issues/2151)) ([2dccaa6](https://github.com/aws-amplify/amplify-category-api/commit/2dccaa6e76deb33627bb31ca90f6f126d53239d7)) | ||
## [2.3.2](https://github.com/aws-amplify/amplify-category-api/compare/@aws-amplify/graphql-relational-transformer@2.3.1...@aws-amplify/graphql-relational-transformer@2.3.2) (2023-12-18) | ||
@@ -8,0 +14,0 @@ |
@@ -41,3 +41,3 @@ "use strict"; | ||
this.directiveList.push(args); | ||
this.relationMap.forEach((_, relationName) => addJoinTableToDatasourceStrategies(context, relationName)); | ||
this.relationMap.forEach((manyToManyRelation, _) => addJoinTableToDatasourceStrategies(context, manyToManyRelation)); | ||
}; | ||
@@ -179,2 +179,8 @@ this.mutateSchema = (context) => { | ||
} | ||
const d1Strategy = (0, graphql_transformer_core_1.getModelDataSourceStrategy)(ctx, d1ExpectedType); | ||
const d2Strategy = (0, graphql_transformer_core_1.getModelDataSourceStrategy)(ctx, d2ExpectedType); | ||
if (((0, graphql_transformer_core_1.isDefaultDynamoDbModelDataSourceStrategy)(d1Strategy) && !(0, graphql_transformer_core_1.isDefaultDynamoDbModelDataSourceStrategy)(d2Strategy)) || | ||
((0, graphql_transformer_core_1.isAmplifyDynamoDbModelDataSourceStrategy)(d1Strategy) && !(0, graphql_transformer_core_1.isAmplifyDynamoDbModelDataSourceStrategy)(d2Strategy))) { | ||
throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} directive cannot be used to relate models with a different DynamoDB-based strategies.`); | ||
} | ||
if (d1ExpectedType !== directive2.object.name.value) { | ||
@@ -342,4 +348,6 @@ throw new graphql_transformer_core_1.InvalidDirectiveError(`@${directiveName} relation '${name}' expects '${d1ExpectedType}' but got '${directive2.object.name.value}'.`); | ||
exports.ManyToManyTransformer = ManyToManyTransformer; | ||
const addJoinTableToDatasourceStrategies = (ctx, relationName) => { | ||
ctx.dataSourceStrategies[relationName] = graphql_transformer_core_1.DDB_DEFAULT_DATASOURCE_STRATEGY; | ||
const addJoinTableToDatasourceStrategies = (ctx, manyToManyRelation) => { | ||
const { name: relationName, directive1: { object: { name: { value: typeName }, }, }, } = manyToManyRelation; | ||
const parentStrategy = (0, graphql_transformer_core_1.getModelDataSourceStrategy)(ctx, typeName); | ||
ctx.dataSourceStrategies[relationName] = parentStrategy; | ||
}; | ||
@@ -346,0 +354,0 @@ function addDirectiveToRelationMap(map, directive) { |
{ | ||
"name": "@aws-amplify/graphql-relational-transformer", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"description": "Amplify GraphQL relational modeling transformers", | ||
@@ -74,3 +74,3 @@ "repository": { | ||
}, | ||
"gitHead": "2ff8c3eda50f582152492e232d6daa3dbaf56821" | ||
"gitHead": "ba7dd9975d34fc13d807dd44fd4989682ff6f700" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
337530
2221