From aedcae36f445c6e990bd94fd29d1b012e1b13787 Mon Sep 17 00:00:00 2001 From: Pavel Lazar <85319655+lazpavel@users.noreply.github.com> Date: Thu, 14 Oct 2021 16:37:21 -0400 Subject: [PATCH] fix(graphql-model-transformer): fixed schema template options check for transformer version (#8449) --- .../service-walkthroughs/appSync-walkthrough.ts | 7 ++++--- packages/amplify-provider-awscloudformation/src/index.ts | 4 +++- .../src/transform-graphql-schema.ts | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/appSync-walkthrough.ts b/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/appSync-walkthrough.ts index c8561d30e01..379a66a4ee9 100644 --- a/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/appSync-walkthrough.ts +++ b/packages/amplify-category-api/src/provider-utils/awscloudformation/service-walkthroughs/appSync-walkthrough.ts @@ -384,7 +384,8 @@ const updateApiInputWalkthrough = async (context, project, resolverConfig, model export const serviceWalkthrough = async (context: $TSContext, defaultValuesFilename, serviceMetadata) => { const resourceName = resourceAlreadyExists(context); - const useExperimentalPipelineTransformer = FeatureFlags.getBoolean('graphQLTransformer.useExperimentalPipelinedTransformer'); + const providerPlugin = await import(context.amplify.getProviderPlugins(context).awscloudformation); + const transformerVersion = providerPlugin.getTransformerVersion(context); if (resourceName) { const errMessage = @@ -402,7 +403,7 @@ export const serviceWalkthrough = async (context: $TSContext, defaultValuesFilen let askToEdit = true; // Schema template selection - const schemaTemplateOptions = useExperimentalPipelineTransformer ? schemaTemplatesV2 : schemaTemplatesV1; + const schemaTemplateOptions = transformerVersion === 2 ? schemaTemplatesV2 : schemaTemplatesV1; const templateSelectionQuestion = { type: inputs[4].type, name: inputs[4].key, @@ -413,7 +414,7 @@ export const serviceWalkthrough = async (context: $TSContext, defaultValuesFilen const { templateSelection } = await inquirer.prompt(templateSelectionQuestion); const schemaFilePath = path.join(graphqlSchemaDir, templateSelection); - schemaContent += useExperimentalPipelineTransformer ? defineGlobalSandboxMode(context) : ''; + schemaContent += transformerVersion === 2 ? defineGlobalSandboxMode(context) : ''; schemaContent += fs.readFileSync(schemaFilePath, 'utf8'); return { diff --git a/packages/amplify-provider-awscloudformation/src/index.ts b/packages/amplify-provider-awscloudformation/src/index.ts index fe455a008fc..e81ad15f11a 100644 --- a/packages/amplify-provider-awscloudformation/src/index.ts +++ b/packages/amplify-provider-awscloudformation/src/index.ts @@ -37,6 +37,7 @@ export { getLocationSupportedRegion, getLocationRegionMapping } from './aws-util import { updateEnv } from './update-env'; import { uploadHooksDirectory } from './utils/hooks-manager'; +import { getTransformerVersion } from './transform-graphql-schema'; function init(context) { return initializer.run(context); @@ -162,5 +163,6 @@ module.exports = { updateEnv, uploadHooksDirectory, getLocationSupportedRegion, - getLocationRegionMapping + getLocationRegionMapping, + getTransformerVersion, }; diff --git a/packages/amplify-provider-awscloudformation/src/transform-graphql-schema.ts b/packages/amplify-provider-awscloudformation/src/transform-graphql-schema.ts index 1c4345020d2..e412f7fdd8b 100644 --- a/packages/amplify-provider-awscloudformation/src/transform-graphql-schema.ts +++ b/packages/amplify-provider-awscloudformation/src/transform-graphql-schema.ts @@ -622,7 +622,7 @@ function getBucketName(context, s3ResourceName, backEndDir) { return { bucketName }; } -function getTransformerVersion(context) { +export function getTransformerVersion(context) { migrateToTransformerVersionFeatureFlag(context); const transformerVersion = FeatureFlags.getNumber('graphQLTransformer.transformerVersion');