How to use apollo-codegen-typescript - 2 common examples

To help you get started, we’ve selected a few apollo-codegen-typescript 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 apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
writeGeneratedFiles(outFiles, outputPath);

      writtenFiles += Object.keys(outFiles).length;
    } else {
      fs.writeFileSync(
        outputPath,
        generatedFiles.map(o => o.content.fileContents).join("\n") + common
      );

      writtenFiles += 1;
    }
  } else if (target === "typescript" || target === "ts") {
    const context = compileToIR(schema, document, options);
    const generatedFiles = generateTypescriptLocalSource(context);
    const generatedGlobalFile = generateTypescriptGlobalSource(context);

    const outFiles: {
      [fileName: string]: BasicGeneratedFile;
    } = {};

    if (
      nextToSources ||
      (fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory())
    ) {
      if (options.globalTypesFile) {
        const globalTypesDir = path.dirname(options.globalTypesFile);
        if (!fs.existsSync(globalTypesDir)) {
          fs.mkdirSync(globalTypesDir);
        }
      } else if (nextToSources && !fs.existsSync(outputPath)) {
        fs.mkdirSync(outputPath);
github apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
});

      writeGeneratedFiles(outFiles, outputPath);

      writtenFiles += Object.keys(outFiles).length;
    } else {
      fs.writeFileSync(
        outputPath,
        generatedFiles.map(o => o.content.fileContents).join("\n") + common
      );

      writtenFiles += 1;
    }
  } else if (target === "typescript" || target === "ts") {
    const context = compileToIR(schema, document, options);
    const generatedFiles = generateTypescriptLocalSource(context);
    const generatedGlobalFile = generateTypescriptGlobalSource(context);

    const outFiles: {
      [fileName: string]: BasicGeneratedFile;
    } = {};

    if (
      nextToSources ||
      (fs.existsSync(outputPath) && fs.statSync(outputPath).isDirectory())
    ) {
      if (options.globalTypesFile) {
        const globalTypesDir = path.dirname(options.globalTypesFile);
        if (!fs.existsSync(globalTypesDir)) {
          fs.mkdirSync(globalTypesDir);
        }
      } else if (nextToSources && !fs.existsSync(outputPath)) {

apollo-codegen-typescript

TypeScript generator module for Apollo Codegen

MIT
Latest version published 3 years ago

Package Health Score

64 / 100
Full package analysis

Similar packages