Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(graphql-model-transformer): fixed schema template options check for transformer version #8449

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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