Skip to content

Commit

Permalink
refactor: add allowGen1Patterns to TransformerFactoryArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilch committed Jul 3, 2024
1 parent c07c917 commit ce75ede
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
22 changes: 11 additions & 11 deletions packages/amplify-graphql-api-construct/.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -3998,7 +3998,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 283
"line": 285
},
"name": "addDynamoDbDataSource",
"parameters": [
Expand Down Expand Up @@ -4047,7 +4047,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 295
"line": 297
},
"name": "addElasticsearchDataSource",
"parameters": [
Expand Down Expand Up @@ -4094,7 +4094,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 305
"line": 307
},
"name": "addEventBridgeDataSource",
"parameters": [
Expand Down Expand Up @@ -4141,7 +4141,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 387
"line": 389
},
"name": "addFunction",
"parameters": [
Expand Down Expand Up @@ -4176,7 +4176,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 316
"line": 318
},
"name": "addHttpDataSource",
"parameters": [
Expand Down Expand Up @@ -4224,7 +4224,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 327
"line": 329
},
"name": "addLambdaDataSource",
"parameters": [
Expand Down Expand Up @@ -4272,7 +4272,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 338
"line": 340
},
"name": "addNoneDataSource",
"parameters": [
Expand Down Expand Up @@ -4311,7 +4311,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 349
"line": 351
},
"name": "addOpenSearchDataSource",
"parameters": [
Expand Down Expand Up @@ -4359,7 +4359,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 362
"line": 364
},
"name": "addRdsDataSource",
"parameters": [
Expand Down Expand Up @@ -4426,7 +4426,7 @@
},
"locationInModule": {
"filename": "src/amplify-graphql-api.ts",
"line": 378
"line": 380
},
"name": "addResolver",
"parameters": [
Expand Down Expand Up @@ -8487,5 +8487,5 @@
}
},
"version": "1.11.1",
"fingerprint": "2wmG0N5kBjtA+aK3rlV8/q7K/7DLfdP+golmlXXr04M="
"fingerprint": "bie/pSK2lDysAxU25A0YKgH5obMspQsx/3xuPdQi6vg="
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ export class AmplifyGraphqlApi extends Construct {

const assetProvider = new AssetProvider(this);

const transformParameters = {
...defaultTranslationBehavior,
...(translationBehavior ?? {}),
};
const executeTransformConfig: ExecuteTransformConfig = {
scope: this,
nestedStackProvider: {
Expand All @@ -204,14 +208,12 @@ export class AmplifyGraphqlApi extends Construct {
...definition.referencedLambdaFunctions,
...functionNameMap,
},
allowGen1Patterns: transformParameters.allowGen1Patterns,
},
authConfig,
stackMapping: stackMappings ?? {},
resolverConfig: this.dataStoreConfiguration ? convertToResolverConfig(this.dataStoreConfiguration) : undefined,
transformParameters: {
...defaultTranslationBehavior,
...(translationBehavior ?? {}),
},
transformParameters,
// CDK construct uses a custom resource. We'll define this explicitly here to remind ourselves that this value is unused in the CDK
// construct flow
rdsLayerMapping: undefined,
Expand Down
3 changes: 2 additions & 1 deletion packages/amplify-graphql-transformer/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { UserDefinedSlot } from '@aws-amplify/graphql-transformer-core';
export const constructTransform: (config: TransformConfig) => GraphQLTransform;

// @public (undocumented)
export const constructTransformerChain: (options?: TransformerFactoryArgs, allowGen1Patterns?: boolean) => TransformerPluginProvider[];
export const constructTransformerChain: (options?: TransformerFactoryArgs) => TransformerPluginProvider[];

// @public (undocumented)
export const executeTransform: (config: ExecuteTransformConfig) => void;
Expand Down Expand Up @@ -56,6 +56,7 @@ export type TransformerFactoryArgs = {
storageConfig?: any;
customTransformers?: TransformerPluginProvider[];
functionNameMap?: Record<string, IFunction>;
allowGen1Patterns?: boolean;
};

// (No @packageDocumentation comment for this package)
Expand Down
16 changes: 8 additions & 8 deletions packages/amplify-graphql-transformer/src/graphql-transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export type TransformerFactoryArgs = {
storageConfig?: any;
customTransformers?: TransformerPluginProvider[];
functionNameMap?: Record<string, IFunction>;
allowGen1Patterns?: boolean;
};

/**
Expand All @@ -56,10 +57,7 @@ export type TransformConfig = {
transformParameters: TransformParameters;
};

export const constructTransformerChain = (
options?: TransformerFactoryArgs,
allowGen1Patterns: boolean = true,
): TransformerPluginProvider[] => {
export const constructTransformerChain = (options?: TransformerFactoryArgs): TransformerPluginProvider[] => {
const modelTransformer = new ModelTransformer();
const authTransformer = new AuthTransformer();
const indexTransformer = new IndexTransformer();
Expand All @@ -70,19 +68,21 @@ export const constructTransformerChain = (
modelTransformer,
new FunctionTransformer(options?.functionNameMap),
new HttpTransformer(),
...(allowGen1Patterns ? [new PredictionsTransformer(options?.storageConfig)] : []),
...(options?.allowGen1Patterns ? [new PredictionsTransformer(options?.storageConfig)] : []),
new PrimaryKeyTransformer(),
indexTransformer,
new HasManyTransformer(),
hasOneTransformer,
...(allowGen1Patterns ? [new ManyToManyTransformer(modelTransformer, indexTransformer, hasOneTransformer, authTransformer)] : []),
...(options?.allowGen1Patterns
? [new ManyToManyTransformer(modelTransformer, indexTransformer, hasOneTransformer, authTransformer)]
: []),
new BelongsToTransformer(),
new DefaultValueTransformer(),
authTransformer,
new MapsToTransformer(),
new SqlTransformer(),
new RefersToTransformer(),
...(allowGen1Patterns ? [new SearchableModelTransformer()] : []),
...(options?.allowGen1Patterns ? [new SearchableModelTransformer()] : []),
...(options?.customTransformers ?? []),
];
};
Expand All @@ -95,7 +95,7 @@ export const constructTransformerChain = (
export const constructTransform = (config: TransformConfig): GraphQLTransform => {
const { transformersFactoryArgs, authConfig, resolverConfig, userDefinedSlots, stackMapping, transformParameters } = config;

const transformers = constructTransformerChain(transformersFactoryArgs, transformParameters.allowGen1Patterns);
const transformers = constructTransformerChain(transformersFactoryArgs);

return new GraphQLTransform({
transformers,
Expand Down

0 comments on commit ce75ede

Please sign in to comment.