Projects STRLCPY graphql-engine Commits 624df9a5
🤬
  • Add `/metadata` endpoint which serves the initial, raw metadata (#459)

    ## Description
    
    As a temporary means of supporting a local development setup, this PR
    adds a `/metadata` endpoint that serves the raw metadata that the engine
    was started with.
    
    ![image](https://github.com/hasura/v3-engine/assets/358550/bf34c3f8-d153-4a93-9044-dbaa15299481)
    
    V3_GIT_ORIGIN_REV_ID: 44c552cfe29ee587fa0d383f7788aacc5579770f
  • Loading...
  • Philip Lykke Carlsen committed with hasura-bot 1 month ago
    624df9a5
    1 parent 93d608c1
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    v3/crates/engine/bin/engine/main.rs
    skipped 127 lines
    128 128  async fn start_engine(server: &ServerOptions) -> Result<(), StartupError> {
    129 129   let auth_config =
    130 130   read_auth_config(&server.authn_config_path).map_err(StartupError::ReadAuth)?;
    131  - let schema = read_schema(&server.metadata_path).map_err(StartupError::ReadSchema)?;
     131 + let (raw_metadata, schema) =
     132 + read_schema(&server.metadata_path).map_err(StartupError::ReadSchema)?;
    132 133   let http_context = HttpContext {
    133 134   client: reqwest::Client::new(),
    134 135   ndc_response_size_limit: None,
    skipped 3 lines
    138 139   schema,
    139 140   auth_config,
    140 141   });
     142 + 
     143 + let metadata_route = Router::new().route("/metadata", get(|| async { raw_metadata }));
    141 144   
    142 145   let graphql_route = Router::new()
    143 146   .route("/graphql", post(handle_request))
    skipped 36 lines
    180 183   let app = Router::new()
    181 184   // serve graphiql at root
    182 185   .route("/", get(graphiql))
     186 + .merge(metadata_route)
    183 187   .merge(graphql_route)
    184 188   .merge(explain_route)
    185 189   .merge(health_route)
    skipped 215 lines
    401 405   response
    402 406  }
    403 407   
    404  -fn read_schema(metadata_path: &PathBuf) -> Result<gql::schema::Schema<GDS>, anyhow::Error> {
     408 +fn read_schema(
     409 + metadata_path: &PathBuf,
     410 +) -> Result<(String, gql::schema::Schema<GDS>), anyhow::Error> {
    405 411   let raw_metadata = std::fs::read_to_string(metadata_path)?;
    406 412   let metadata = open_dds::Metadata::from_json_str(&raw_metadata)?;
    407  - Ok(engine::build::build_schema(metadata)?)
     413 + Ok((raw_metadata, engine::build::build_schema(metadata)?))
    408 414  }
    409 415   
    410 416  fn read_auth_config(path: &PathBuf) -> Result<AuthConfig, anyhow::Error> {
    skipped 6 lines
Please wait...
Page is in error, reload to recover