generate_from_config_file

Function generate_from_config_file 

Source
pub async fn generate_from_config_file<P: AsRef<Path>>(
    config_path: P,
) -> Result<()>
Expand description

Generates ORM code directly from a configuration file path.

This is a convenience function that combines configuration loading and code generation into a single call. It automatically detects the configuration format (TOML or YAML) and creates the appropriate code generator.

§Supported Configuration Formats

  • TOML: graphql-codegen-rust.toml or any .toml file
  • YAML: codegen.yml, codegen.yaml (requires yaml-codegen-config feature)

§Parameters

  • config_path: Path to the configuration file. Can be any type that converts to Path.

§Returns

  • Ok(()) on successful code generation
  • Err(anyhow::Error) with context about what failed

§Errors

This function can fail due to:

  • Configuration file not found or unreadable
  • Invalid configuration format or content
  • Network issues during GraphQL introspection
  • Code generation failures

§Example

use graphql_codegen_rust::generate_from_config_file;

// Generate from TOML config
generate_from_config_file("graphql-codegen-rust.toml").await?;

// Generate from YAML config (if feature enabled)
generate_from_config_file("codegen.yml").await?;