private uploadAppSyncFiles()

in src/export-backend-asset-handler/index.ts [290:325]


  private uploadAppSyncFiles(resourceName: string): BucketDeployment {
    const filePath = path.join(
      this.exportPath,
      API_CATEGORY.NAME,
      resourceName,
      AMPLIFY_APPSYNC_FILES,
    );
    if (!fs.existsSync(filePath)) {
      throw new Error('Cannot find appsync resources');
    }
    const destinationKey = `assets/${AMPLIFY_APPSYNC_FILES}/${v4().replace(
      '-',
      '',
    )}`;
    const bucketDeployment = new BucketDeployment(
      this,
      `Appsync-${resourceName}-deployment`,
      {
        destinationBucket: this.deploymentBucket,
        sources: [Source.asset(filePath)],
        destinationKeyPrefix: destinationKey,
      },
    );

    const stacks = this.exportManifest.props.loadNestedStacks;
    const logicalId = `${API_CATEGORY.NAME}${resourceName}`;
    if (stacks && stacks[logicalId]) {
      const parameters = stacks[logicalId].parameters;
      if (parameters) {
        parameters[STACK_PARAMETERS.API.DEPLOYMENT_BUCKET_NAME] =
          this.deploymentBucket.bucketName;
        parameters[STACK_PARAMETERS.API.DEPLOYMENT_ROOT_KEY] = destinationKey;
      }
    }
    return bucketDeployment;
  }