How to use amplify-codegen - 7 common examples

To help you get started, we’ve selected a few amplify-codegen examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws-amplify / amplify-cli / packages / amplify-provider-awscloudformation / lib / graphql-codegen.js View on Github external
async function prePushGraphQLCodegen(context, createResources, updateResources) {
  createResources = createResources.filter(resource => resource.service === 'AppSync');
  // There can only be one appsync resource
  if (createResources.length > 0) {
    const resource = createResources[0];
    const { resourceName } = resource;
    graphQLConfig = await prePushAddGraphQLCodegenHook(context, resourceName);
    return;
  }
  if (updateResources.length > 0) {
    const resource = updateResources[0];
    const { resourceName } = resource;
    graphQLConfig = await prePushUpdateGraphQLCodegenHook(context, resourceName);
  }
}
github aws-amplify / amplify-cli / packages / amplify-provider-awscloudformation / lib / graphql-codegen.js View on Github external
async function prePushGraphQLCodegen(context, createResources, updateResources) {
  createResources = createResources.filter(resource => resource.service === 'AppSync');
  // There can only be one appsync resource
  if (createResources.length > 0) {
    const resource = createResources[0];
    const { resourceName } = resource;
    graphQLConfig = await prePushAddGraphQLCodegenHook(context, resourceName);
    return;
  }
  if (updateResources.length > 0) {
    const resource = updateResources[0];
    const { resourceName } = resource;
    graphQLConfig = await prePushUpdateGraphQLCodegenHook(context, resourceName);
  }
}
github aws-amplify / amplify-cli / packages / amplify-util-mock / src / api / api.ts View on Github external
private async generateCode(context, transformerOutput = null) {
    try {
      context.print.info('Running GraphQL codegen');
      const { projectPath } = context.amplify.getEnvInfo();
      const schemaPath = path.join(projectPath, 'amplify', 'backend', 'api', this.apiName, 'build', 'schema.graphql');
      if (transformerOutput) {
        fs.writeFileSync(schemaPath, transformerOutput.schema);
      }
      if (!isCodegenConfigured(context, this.apiName)) {
        await add(context);
      } else {
        switchToSDLSchema(context, this.apiName);
        await generate(context);
      }
    } catch (e) {
      context.print.info(`Failed to run GraphQL codegen with following error:\n${e.message}`);
    }
  }
github aws-amplify / amplify-cli / packages / amplify-util-mock / src / api / api.ts View on Github external
private async generateCode(context, transformerOutput = null) {
    try {
      context.print.info('Running GraphQL codegen');
      const { projectPath } = context.amplify.getEnvInfo();
      const schemaPath = path.join(projectPath, 'amplify', 'backend', 'api', this.apiName, 'build', 'schema.graphql');
      if (transformerOutput) {
        fs.writeFileSync(schemaPath, transformerOutput.schema);
      }
      if (!isCodegenConfigured(context, this.apiName)) {
        await add(context);
      } else {
        switchToSDLSchema(context, this.apiName);
        await generate(context);
      }
    } catch (e) {
      context.print.info(`Failed to run GraphQL codegen with following error:\n${e.message}`);
    }
  }
github aws-amplify / amplify-cli / packages / amplify-util-mock / src / api / api.ts View on Github external
private async generateCode(context, transformerOutput = null) {
    try {
      context.print.info('Running GraphQL codegen');
      const { projectPath } = context.amplify.getEnvInfo();
      const schemaPath = path.join(projectPath, 'amplify', 'backend', 'api', this.apiName, 'build', 'schema.graphql');
      if (transformerOutput) {
        fs.writeFileSync(schemaPath, transformerOutput.schema);
      }
      if (!isCodegenConfigured(context, this.apiName)) {
        await add(context);
      } else {
        switchToSDLSchema(context, this.apiName);
        await generate(context);
      }
    } catch (e) {
      context.print.info(`Failed to run GraphQL codegen with following error:\n${e.message}`);
    }
  }
github aws-amplify / amplify-cli / packages / amplify-util-mock / src / api / api.ts View on Github external
private async generateCode(context, transformerOutput = null) {
    try {
      context.print.info('Running GraphQL codegen');
      const { projectPath } = context.amplify.getEnvInfo();
      const schemaPath = path.join(projectPath, 'amplify', 'backend', 'api', this.apiName, 'build', 'schema.graphql');
      if (transformerOutput) {
        fs.writeFileSync(schemaPath, transformerOutput.schema);
      }
      if (!isCodegenConfigured(context, this.apiName)) {
        await add(context);
      } else {
        switchToSDLSchema(context, this.apiName);
        await generate(context);
      }
    } catch (e) {
      context.print.info(`Failed to run GraphQL codegen with following error:\n${e.message}`);
    }
  }
github aws-amplify / amplify-cli / packages / amplify-provider-awscloudformation / lib / graphql-codegen.js View on Github external
async function postPushGraphQLCodegen(context) {
  await postPushGraphQLCodegenHook(context, graphQLConfig);
}