How to use the apollo-codegen-core/lib/compiler/legacyIR.compileToLegacyIR function in apollo-codegen-core

To help you get started, we’ve selected a few apollo-codegen-core 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-codegen-flow-legacy / src / __tests__ / codeGeneration.js View on Github external
const compileFromSource = source => {
    const document = parse(source);
    const context = compileToLegacyIR(schema, document, {
      mergeInFieldsFromFragmentSpreads: true,
      addTypename: true
    });
    generator.context = context;
    return context;
  };
github apollographql / apollo-tooling / packages / apollo-codegen-typescript-legacy / src / __tests__ / codeGeneration.js View on Github external
compileFromSource = source => {
      const document = parse(source);
      const context = compileToLegacyIR(schema, document, {
        mergeInFieldsFromFragmentSpreads: true,
        addTypename: true
      });
      generator.context = context;
      return context;
    };
github apollographql / apollo-tooling / packages / apollo-codegen-scala / src / __tests__ / codeGeneration.ts View on Github external
compileFromSource = (
      source,
      options = { generateOperationIds: false, namespace: undefined }
    ) => {
      const document = parse(source);
      let context = compileToLegacyIR(schema, document);
      options.generateOperationIds &&
        Object.assign(context.options, {
          generateOperationIds: true,
          operationIdsMap: {}
        });
      options.namespace &&
        Object.assign(context.options, { namespace: options.namespace });
      generator.context = context;
      return context;
    };
github apollographql / apollo-tooling / packages / apollo / src / generate.ts View on Github external
writeGeneratedFiles(outFiles, path.resolve("."));

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

      writtenFiles += 1;
    }
  } else {
    let output;
    const context = compileToLegacyIR(schema, document, options);
    switch (target) {
      case "json":
        output = serializeToJSON(context);
        break;
      case "scala":
        output = generateScalaSource(context);
    }

    if (outputPath) {
      fs.writeFileSync(outputPath, output);
      writtenFiles += 1;
    } else {
      console.log(output);
    }
  }