Skip to content

Commit

Permalink
fix(graphql-model-transformer): fixed schema template options check f…
Browse files Browse the repository at this point in the history
…or transformer version (#8449)
  • Loading branch information
lazpavel authored Oct 14, 2021
1 parent 4d553e5 commit aedcae3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion packages/amplify-provider-awscloudformation/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -162,5 +163,6 @@ module.exports = {
updateEnv,
uploadHooksDirectory,
getLocationSupportedRegion,
getLocationRegionMapping
getLocationRegionMapping,
getTransformerVersion,
};
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit aedcae3

Please sign in to comment.