INNER CODE UNIT · Rust

get_set_query_from_file

graphql-rust/graphql-client · graphql_client_codegen/src/lib.rs:66

fn get_set_query_from_file(query_path: &std::path::Path) -> (String, QueryDocument) {
    get_set_cached(&QUERY_CACHE, query_path, || {
        let query_string = read_file(query_path).unwrap();
        let query_document = query_document(&query_string).unwrap();
        (query_string, query_document)
    })
}

fn get_set_schema_from_file(schema_path: &std::path::Path) -> Schema {
    get_set_cached(&SCHEMA_CACHE, schema_path, || {
        let schema_extension = schema_path
            .extension()
            .map(|ext| ext.to_str().expect("Path must be valid UTF-8"))
            .unwrap_or("<no extension>");
        let schema_string = read_file(schema_path).unwrap();
        match schema_extension {
            "graphql" | "graphqls"| "gql" => {
                let s = graphql_parser::schema::parse_schema::<&str>(&schema_string).map_err(|parser_error| GeneralError(format!("Parser error: {}", parser_error))).unwrap();

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…