diff --git a/Cargo.lock b/Cargo.lock index 7d6ef45a..95c988af 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -603,9 +603,9 @@ dependencies = [ "git-url-parse", "hn_api", "itertools", - "lazy_static", "maplit", "octorust", + "once_cell", "regex", "reqwest 0.11.10", "ron 0.6.6", @@ -2074,7 +2074,7 @@ version = "0.1.6" dependencies = [ "async-graphql-parser", "async-graphql-value", - "lazy_static", + "once_cell", "pyo3", "trustfall_core", ] @@ -2592,8 +2592,8 @@ dependencies = [ "async-graphql-parser", "async-graphql-value", "derive-new", - "lazy_static", "maplit", + "once_cell", "trustfall_core", ] @@ -3331,7 +3331,7 @@ dependencies = [ "csv", "feed-rs", "hn_api", - "lazy_static", + "once_cell", "regex", "reqwest 0.11.10", "ron 0.7.1", @@ -3349,8 +3349,8 @@ dependencies = [ "async-graphql-value", "chrono", "itertools", - "lazy_static", "maplit", + "once_cell", "regex", "ron 0.6.6", "serde", @@ -3408,8 +3408,8 @@ dependencies = [ "anyhow", "async-graphql-parser", "itertools", - "lazy_static", "maplit", + "once_cell", "ron 0.8.0", "serde", "trustfall_core", diff --git a/demo-hytradboi/Cargo.toml b/demo-hytradboi/Cargo.toml index 4d9145d9..ac1b4103 100644 --- a/demo-hytradboi/Cargo.toml +++ b/demo-hytradboi/Cargo.toml @@ -16,7 +16,7 @@ futures-executor = "0.3.21" git-url-parse = "0.4.0" hn_api = "0.1.0" itertools = "0.10.3" -lazy_static = "1.4.0" +once_cell = "1.17" maplit = "1.0.2" octorust = "0.1.35" regex = "1.5.4" diff --git a/demo-hytradboi/src/adapter.rs b/demo-hytradboi/src/adapter.rs index 81b48e8a..7f8ed31c 100644 --- a/demo-hytradboi/src/adapter.rs +++ b/demo-hytradboi/src/adapter.rs @@ -4,8 +4,8 @@ use std::{fs, rc::Rc, sync::Arc}; use git_url_parse::GitUrl; use hn_api::{types::Item, HnClient}; -use lazy_static::__Deref; use octorust::types::{ContentFile, FullRepository}; +use once_cell::sync::Lazy; use tokio::runtime::Runtime; use trustfall_core::{ interpreter::{ @@ -24,10 +24,13 @@ use crate::{ const USER_AGENT: &str = "demo-hytradboi (github.com/obi1kenobi/trustfall)"; -lazy_static! { - static ref HN_CLIENT: HnClient = HnClient::init().unwrap(); - static ref CRATES_CLIENT: consecrates::Client = consecrates::Client::new(USER_AGENT); - static ref GITHUB_CLIENT: octorust::Client = octorust::Client::new( +static HN_CLIENT: Lazy = Lazy::new(|| HnClient::init().unwrap()); + +static CRATES_CLIENT: Lazy = + Lazy::new(|| consecrates::Client::new(USER_AGENT)); + +static GITHUB_CLIENT: Lazy = Lazy::new(|| { + octorust::Client::new( USER_AGENT, Some(octorust::auth::Credentials::Token( std::env::var("GITHUB_TOKEN").unwrap_or_else(|_| { @@ -35,17 +38,21 @@ lazy_static! { .expect("could not find creds file") .trim() .to_string() - }) + }), )), ) - .unwrap(); - static ref REPOS_CLIENT: octorust::repos::Repos = - octorust::repos::Repos::new(GITHUB_CLIENT.clone()); - static ref RUNTIME: Runtime = tokio::runtime::Builder::new_current_thread() + .unwrap() +}); + +static REPOS_CLIENT: Lazy = + Lazy::new(|| octorust::repos::Repos::new(GITHUB_CLIENT.clone())); + +static RUNTIME: Lazy = Lazy::new(|| { + tokio::runtime::Builder::new_current_thread() .enable_all() .build() - .unwrap(); -} + .unwrap() +}); pub struct DemoAdapter; @@ -119,7 +126,7 @@ impl DemoAdapter { fn most_downloaded_crates(&self) -> VertexIterator<'static, Vertex> { Box::new( - CratesPager::new(CRATES_CLIENT.deref()) + CratesPager::new(&CRATES_CLIENT) .into_iter() .map(|x| x.into()), ) @@ -596,7 +603,7 @@ impl Adapter<'static> for DemoAdapter { let neighbors: VertexIterator<'static, Self::Vertex> = match vertex { None => Box::new(std::iter::empty()), Some(vertex) => Box::new( - WorkflowsPager::new(GITHUB_CLIENT.clone(), vertex, RUNTIME.deref()) + WorkflowsPager::new(GITHUB_CLIENT.clone(), vertex, &RUNTIME) .into_iter() .map(|x| x.into()), ), diff --git a/demo-hytradboi/src/main.rs b/demo-hytradboi/src/main.rs index 1b078a82..35c6d96a 100644 --- a/demo-hytradboi/src/main.rs +++ b/demo-hytradboi/src/main.rs @@ -5,25 +5,21 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use adapter::DemoAdapter; +use once_cell::sync::Lazy; use serde::Deserialize; use trustfall_core::ir::TransparentValue; use trustfall_core::{ frontend::parse, interpreter::execution::interpret_ir, ir::FieldValue, schema::Schema, }; -#[macro_use] -extern crate lazy_static; - mod actions_parser; mod adapter; mod pagers; mod util; mod vertex; -lazy_static! { - static ref SCHEMA: Schema = - Schema::parse(fs::read_to_string("./schema.graphql").unwrap()).unwrap(); -} +static SCHEMA: Lazy = + Lazy::new(|| Schema::parse(fs::read_to_string("./schema.graphql").unwrap()).unwrap()); #[derive(Debug, Clone, Deserialize)] struct InputQuery<'a> { diff --git a/experiments/schemaless/Cargo.toml b/experiments/schemaless/Cargo.toml index edc1abde..cf082f1a 100644 --- a/experiments/schemaless/Cargo.toml +++ b/experiments/schemaless/Cargo.toml @@ -9,6 +9,6 @@ edition = "2021" async-graphql-parser = "2.11.3" async-graphql-value = "2.11.3" derive-new = "0.5.9" -lazy_static = "1.4.0" +once_cell = "1.17" maplit = "1.0.2" trustfall_core = { path = "../../trustfall_core" } diff --git a/pytrustfall/Cargo.toml b/pytrustfall/Cargo.toml index 90dc9248..8565266e 100644 --- a/pytrustfall/Cargo.toml +++ b/pytrustfall/Cargo.toml @@ -24,6 +24,6 @@ crate-type = ["cdylib", "rlib"] [dependencies] async-graphql-parser = "2.11.3" async-graphql-value = "2.11.3" -lazy_static = "1.4.0" +once_cell = "1.17" pyo3 = { version = "0.17.2", features = ["extension-module"] } trustfall_core = { path = "../trustfall_core" } diff --git a/trustfall/Cargo.toml b/trustfall/Cargo.toml index c2a7be8c..3987722c 100644 --- a/trustfall/Cargo.toml +++ b/trustfall/Cargo.toml @@ -23,7 +23,7 @@ ron = "0.7.0" serde = { version = "^1.0", features = ["derive"] } serde_json = "1.0.69" feed-rs = "1.0.0" -lazy_static = "1.4.0" +once_cell = "1.17" reqwest = { version = "0.11.6", features = ["blocking", "json"] } hn_api = "0.1.0" csv = "1.1.6" diff --git a/trustfall/examples/feeds/main.rs b/trustfall/examples/feeds/main.rs index d6f42c48..7fbfa36e 100644 --- a/trustfall/examples/feeds/main.rs +++ b/trustfall/examples/feeds/main.rs @@ -8,12 +8,10 @@ use std::{ }; use feed_rs::{model::Feed, parser}; +use once_cell::sync::Lazy; use serde::Deserialize; use trustfall::{execute_query, FieldValue, Schema, TransparentValue}; -#[macro_use] -extern crate lazy_static; - use crate::adapter::FeedAdapter; mod adapter; @@ -25,10 +23,8 @@ const WIRED_FEED_URI: &str = "https://www.wired.com/feed"; const PCGAMER_FEED_LOCATION: &str = "/tmp/feeds-pcgamer.xml"; const WIRED_FEED_LOCATION: &str = "/tmp/feeds-wired.xml"; -lazy_static! { - static ref SCHEMA: Schema = - Schema::parse(util::read_file("./examples/feeds/feeds.graphql")).unwrap(); -} +static SCHEMA: Lazy = + Lazy::new(|| Schema::parse(util::read_file("./examples/feeds/feeds.graphql")).unwrap()); #[derive(Debug, Clone, Deserialize)] struct InputQuery<'a> { diff --git a/trustfall/examples/hackernews/adapter.rs b/trustfall/examples/hackernews/adapter.rs index 0f087e6b..3e28dab7 100644 --- a/trustfall/examples/hackernews/adapter.rs +++ b/trustfall/examples/hackernews/adapter.rs @@ -3,6 +3,7 @@ use std::collections::HashSet; use hn_api::{types::Item, HnClient}; +use once_cell::sync::Lazy; use trustfall::{ provider::{ field_property, resolve_coercion_using_schema, resolve_neighbors_with, @@ -14,9 +15,7 @@ use trustfall::{ use crate::{vertex::Vertex, SCHEMA}; -lazy_static! { - static ref CLIENT: HnClient = HnClient::init().expect("HnClient instantiated"); -} +static CLIENT: Lazy = Lazy::new(|| HnClient::init().expect("HnClient instantiated")); #[derive(Debug, Clone, Default)] pub struct HackerNewsAdapter { diff --git a/trustfall/examples/hackernews/main.rs b/trustfall/examples/hackernews/main.rs index 411c90f4..85164204 100644 --- a/trustfall/examples/hackernews/main.rs +++ b/trustfall/examples/hackernews/main.rs @@ -2,22 +2,19 @@ use std::collections::BTreeMap; use std::sync::Arc; use std::{env, process}; +use once_cell::sync::Lazy; use serde::Deserialize; use trustfall::{execute_query, FieldValue, Schema, TransparentValue}; use crate::adapter::HackerNewsAdapter; -#[macro_use] -extern crate lazy_static; - pub mod adapter; mod util; pub mod vertex; -lazy_static! { - static ref SCHEMA: Schema = - Schema::parse(util::read_file("./examples/hackernews/hackernews.graphql")).unwrap(); -} +static SCHEMA: Lazy = Lazy::new(|| { + Schema::parse(util::read_file("./examples/hackernews/hackernews.graphql")).unwrap() +}); #[derive(Debug, Clone, Deserialize)] struct InputQuery<'a> { diff --git a/trustfall/examples/weather/main.rs b/trustfall/examples/weather/main.rs index 63dda00c..da61fd83 100644 --- a/trustfall/examples/weather/main.rs +++ b/trustfall/examples/weather/main.rs @@ -5,6 +5,7 @@ use std::io::{BufRead, BufReader, BufWriter, Write}; use std::sync::Arc; use std::{env, process}; +use once_cell::sync::Lazy; use serde::Deserialize; use trustfall::{execute_query, FieldValue, Schema, TransparentValue}; @@ -13,18 +14,14 @@ use crate::{ metar::{CsvMetarReport, MetarReport}, }; -#[macro_use] -extern crate lazy_static; - mod adapter; mod metar; mod util; -lazy_static! { - static ref SCHEMA: Schema = - Schema::parse(util::read_file("./examples/weather/metar_weather.graphql")) - .expect("failed to parse schema"); -} +static SCHEMA: Lazy = Lazy::new(|| { + Schema::parse(util::read_file("./examples/weather/metar_weather.graphql")) + .expect("failed to parse schema") +}); const METAR_DOC_URL: &str = "https://aviationweather.gov/adds/dataserver_current/current/metars.cache.csv"; diff --git a/trustfall/examples/weather/metar.rs b/trustfall/examples/weather/metar.rs index 7f8cfa93..2dae4987 100644 --- a/trustfall/examples/weather/metar.rs +++ b/trustfall/examples/weather/metar.rs @@ -1,6 +1,7 @@ use std::fmt; use chrono::{DateTime, Utc}; +use once_cell::sync::Lazy; use regex::Regex; use serde::{de::Visitor, Deserialize, Deserializer}; @@ -225,8 +226,8 @@ static METAR_WIND_VARIABILITY_PATTERN: &str = r"(?:[0-9/]{3}V[0-9/]{3} )?"; // |raw meters|vis.ok| statute mi | static METAR_VISIBILITY_PATTERN: &str = r"(?:[0-9]{4}|CAVOK|(?:[0-9/ ]+SM)) "; -lazy_static! { - static ref METAR_VISIBILITY_CAPTURE_PATTERN: String = METAR_STATION_AND_DATE_PATTERN.to_owned() +static METAR_VISIBILITY_CAPTURE_PATTERN: Lazy = Lazy::new(|| { + METAR_STATION_AND_DATE_PATTERN.to_owned() + METAR_AUTO_OPTIONAL_MARKER_PATTERN + "(?:" + METAR_WIND_PATTERN @@ -234,10 +235,11 @@ lazy_static! { + METAR_WIND_VARIABILITY_PATTERN + "(" + METAR_VISIBILITY_PATTERN - + ")"; - static ref METAR_VISIBILITY_CAPTURE_RE: Regex = - Regex::new(&METAR_VISIBILITY_CAPTURE_PATTERN).unwrap(); -} + + ")" +}); + +static METAR_VISIBILITY_CAPTURE_RE: Lazy = + Lazy::new(|| Regex::new(&METAR_VISIBILITY_CAPTURE_PATTERN).unwrap()); fn get_visibility(raw_metar: &str) -> Visibility { if let Some(capture) = METAR_VISIBILITY_CAPTURE_RE.captures(raw_metar) { diff --git a/trustfall_core/Cargo.toml b/trustfall_core/Cargo.toml index 1cddb5ba..216b58e9 100644 --- a/trustfall_core/Cargo.toml +++ b/trustfall_core/Cargo.toml @@ -29,7 +29,7 @@ serde = { version = "^1.0", features = ["derive", "rc"] } async-graphql-parser = "^2.11.3" async-graphql-value = "^2.11.3" maplit = "^1.0.2" -lazy_static = "^1.4.0" +once_cell = "1.17" smallvec = { version = "^1.6.1", features = ["serde"] } chrono = { version = "0.4.19", features = ["serde"] } regex = "1.5.4" diff --git a/trustfall_core/fuzz/Cargo.lock b/trustfall_core/fuzz/Cargo.lock index 7350cdeb..8ef07c9f 100644 --- a/trustfall_core/fuzz/Cargo.lock +++ b/trustfall_core/fuzz/Cargo.lock @@ -338,12 +338,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.141" @@ -653,14 +647,14 @@ dependencies = [ [[package]] name = "trustfall_core" -version = "0.4.0-beta.1" +version = "0.5.0" dependencies = [ "async-graphql-parser", "async-graphql-value", "chrono", "itertools", - "lazy_static", "maplit", + "once_cell", "regex", "ron 0.6.6", "serde", @@ -677,9 +671,9 @@ dependencies = [ "byteorder", "globset", "itertools", - "lazy_static", "libfuzzer-sys", "maplit", + "once_cell", "regex", "ron 0.7.1", "serde", diff --git a/trustfall_core/fuzz/Cargo.toml b/trustfall_core/fuzz/Cargo.toml index c1b26a09..0c13a0f3 100644 --- a/trustfall_core/fuzz/Cargo.toml +++ b/trustfall_core/fuzz/Cargo.toml @@ -12,7 +12,7 @@ cargo-fuzz = true async-graphql-parser = "^2.11.3" async-graphql-value = "^2.11.3" byteorder = "1" -lazy_static = "1.4.0" +once_cell = "1.17" ron = "0.7.0" serde = { version = "^1.0", features = ["derive"] } libfuzzer-sys = "0.4" diff --git a/trustfall_core/fuzz/fuzz_targets/adapter_batching/mod.rs b/trustfall_core/fuzz/fuzz_targets/adapter_batching/mod.rs index 784499a9..a095fa6c 100644 --- a/trustfall_core/fuzz/fuzz_targets/adapter_batching/mod.rs +++ b/trustfall_core/fuzz/fuzz_targets/adapter_batching/mod.rs @@ -10,7 +10,7 @@ use std::sync::Arc; use byteorder::{LittleEndian, ReadBytesExt}; use globset::GlobBuilder; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use serde::Deserialize; use walkdir::WalkDir; @@ -194,11 +194,7 @@ pub(crate) struct TestIRQuery { type QueryAndArgs = (Arc, Arc, FieldValue>>); -lazy_static! { - static ref QUERY_DATA: Vec = load_queries(); -} - -fn load_queries() -> Vec { +static QUERY_DATA: Lazy> = Lazy::new(|| { let mut buf = PathBuf::from(env!("CARGO_MANIFEST_DIR")); buf.pop(); buf.push("test_data/tests/valid_queries"); @@ -245,7 +241,7 @@ fn load_queries() -> Vec { } outputs -} +}); impl<'a> TryFrom<&'a [u8]> for TestCase<'a> { type Error = (); diff --git a/trustfall_core/fuzz/fuzz_targets/frontend.rs b/trustfall_core/fuzz/fuzz_targets/frontend.rs index 09c500b2..cfa22095 100644 --- a/trustfall_core/fuzz/fuzz_targets/frontend.rs +++ b/trustfall_core/fuzz/fuzz_targets/frontend.rs @@ -7,7 +7,7 @@ use std::fs; use std::path::PathBuf; use async_graphql_parser::{parse_query, parse_schema, types::ServiceDocument}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use trustfall_core::{ frontend::{error::FrontendError, parse_doc}, graphql_query::error::ParseError, @@ -22,9 +22,7 @@ fn get_service_doc() -> ServiceDocument { parse_schema(fs::read_to_string(schema_path).unwrap()).unwrap() } -lazy_static! { - static ref SCHEMA: Schema = Schema::new(get_service_doc()).unwrap(); -} +static SCHEMA: Lazy = Lazy::new(|| Schema::new(get_service_doc()).unwrap()); fuzz_target!(|data: &[u8]| { if let Ok(query_string) = std::str::from_utf8(data) { diff --git a/trustfall_core/fuzz/fuzz_targets/frontend_numbers.rs b/trustfall_core/fuzz/fuzz_targets/frontend_numbers.rs index 9abc5edf..37ecc89b 100644 --- a/trustfall_core/fuzz/fuzz_targets/frontend_numbers.rs +++ b/trustfall_core/fuzz/fuzz_targets/frontend_numbers.rs @@ -7,7 +7,7 @@ use std::fs; use std::path::PathBuf; use async_graphql_parser::{parse_query, parse_schema, types::ServiceDocument}; -use lazy_static::lazy_static; +use once_cell::sync::Lazy; use trustfall_core::{ frontend::{error::FrontendError, parse_doc}, graphql_query::error::ParseError, @@ -22,9 +22,7 @@ fn get_service_doc() -> ServiceDocument { parse_schema(fs::read_to_string(schema_path).unwrap()).unwrap() } -lazy_static! { - static ref SCHEMA: Schema = Schema::new(get_service_doc()).unwrap(); -} +static SCHEMA: Lazy = Lazy::new(|| Schema::new(get_service_doc()).unwrap()); fuzz_target!(|data: &[u8]| { if let Ok(query_string) = std::str::from_utf8(data) { diff --git a/trustfall_core/src/frontend/mod.rs b/trustfall_core/src/frontend/mod.rs index 1a6172c6..ec920c3d 100644 --- a/trustfall_core/src/frontend/mod.rs +++ b/trustfall_core/src/frontend/mod.rs @@ -1411,6 +1411,7 @@ mod tests { path::{Path, PathBuf}, }; + use once_cell::sync::Lazy; use trustfall_filetests_macros::parameterize; use crate::{ @@ -1419,20 +1420,21 @@ mod tests { test_types::{TestIRQuery, TestIRQueryResult, TestParsedGraphQLQueryResult}, }; - lazy_static! { - static ref FILESYSTEM_SCHEMA: Schema = - Schema::parse(fs::read_to_string("test_data/schemas/filesystem.graphql").unwrap()) - .unwrap(); - static ref NUMBERS_SCHEMA: Schema = - Schema::parse(fs::read_to_string("test_data/schemas/numbers.graphql").unwrap()) - .unwrap(); - static ref NULLABLES_SCHEMA: Schema = - Schema::parse(fs::read_to_string("test_data/schemas/nullables.graphql").unwrap()) - .unwrap(); - static ref RECURSES_SCHEMA: Schema = - Schema::parse(fs::read_to_string("test_data/schemas/recurses.graphql").unwrap()) - .unwrap(); - } + static FILESYSTEM_SCHEMA: Lazy = Lazy::new(|| { + Schema::parse(fs::read_to_string("test_data/schemas/filesystem.graphql").unwrap()).unwrap() + }); + + static NUMBERS_SCHEMA: Lazy = Lazy::new(|| { + Schema::parse(fs::read_to_string("test_data/schemas/numbers.graphql").unwrap()).unwrap() + }); + + static NULLABLES_SCHEMA: Lazy = Lazy::new(|| { + Schema::parse(fs::read_to_string("test_data/schemas/nullables.graphql").unwrap()).unwrap() + }); + + static RECURSES_SCHEMA: Lazy = Lazy::new(|| { + Schema::parse(fs::read_to_string("test_data/schemas/recurses.graphql").unwrap()).unwrap() + }); #[test] fn test_schemas_load_correctly() { diff --git a/trustfall_core/src/ir/mod.rs b/trustfall_core/src/ir/mod.rs index 384b4a9f..a0ebd41c 100644 --- a/trustfall_core/src/ir/mod.rs +++ b/trustfall_core/src/ir/mod.rs @@ -12,6 +12,7 @@ use std::{ use async_graphql_parser::types::{BaseType, Type}; use async_graphql_value::Name; +use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use crate::frontend::error::FilterTypeError; @@ -24,11 +25,14 @@ pub use self::value::{FieldValue, TransparentValue}; pub(crate) const TYPENAME_META_FIELD: &str = "__typename"; -lazy_static! { - pub(crate) static ref TYPENAME_META_FIELD_NAME: Name = Name::new(TYPENAME_META_FIELD); - pub(crate) static ref TYPENAME_META_FIELD_TYPE: Type = Type::new("String!").unwrap(); - pub(crate) static ref TYPENAME_META_FIELD_ARC: Arc = Arc::from(TYPENAME_META_FIELD); -} +pub(crate) static TYPENAME_META_FIELD_NAME: Lazy = + Lazy::new(|| Name::new(TYPENAME_META_FIELD)); + +pub(crate) static TYPENAME_META_FIELD_TYPE: Lazy = + Lazy::new(|| Type::new("String!").unwrap()); + +pub(crate) static TYPENAME_META_FIELD_ARC: Lazy> = + Lazy::new(|| Arc::from(TYPENAME_META_FIELD)); /// Unique vertex ID identifying a specific vertex in a Trustfall query #[doc(alias("vertex", "node"))] @@ -229,12 +233,10 @@ pub enum FoldSpecificFieldKind { Count, // Represents the number of elements in an IRFold's component. } -lazy_static! { - static ref NON_NULL_INT_TYPE: Type = Type { - base: BaseType::Named(Name::new("Int")), - nullable: false, - }; -} +static NON_NULL_INT_TYPE: Lazy = Lazy::new(|| Type { + base: BaseType::Named(Name::new("Int")), + nullable: false, +}); impl FoldSpecificFieldKind { pub fn field_type(&self) -> &Type { diff --git a/trustfall_core/src/lib.rs b/trustfall_core/src/lib.rs index 8a7d7b82..420aa36d 100644 --- a/trustfall_core/src/lib.rs +++ b/trustfall_core/src/lib.rs @@ -6,9 +6,6 @@ #[macro_use] extern crate maplit; -#[macro_use] -extern crate lazy_static; - pub mod frontend; pub mod graphql_query; pub mod interpreter; diff --git a/trustfall_core/src/schema/mod.rs b/trustfall_core/src/schema/mod.rs index 6b022ff7..89e04fb2 100644 --- a/trustfall_core/src/schema/mod.rs +++ b/trustfall_core/src/schema/mod.rs @@ -17,6 +17,7 @@ use async_graphql_parser::{ pub use ::async_graphql_parser::Error; use async_graphql_value::Name; use itertools::Itertools; +use once_cell::sync::Lazy; use serde::{Deserialize, Serialize}; use crate::ir::types::{get_base_named_type, is_argument_type_valid, is_scalar_only_subtype}; @@ -70,15 +71,15 @@ impl Add for &FieldOrigin { } } -lazy_static! { - pub(crate) static ref BUILTIN_SCALARS: HashSet<&'static str> = hashset! { +pub(crate) static BUILTIN_SCALARS: Lazy> = Lazy::new(|| { + hashset! { "Int", "Float", "String", "Boolean", "ID", - }; -} + } +}); const RESERVED_PREFIX: &str = "__"; diff --git a/trustfall_testbin/Cargo.toml b/trustfall_testbin/Cargo.toml index b685de12..319ce2eb 100644 --- a/trustfall_testbin/Cargo.toml +++ b/trustfall_testbin/Cargo.toml @@ -10,7 +10,7 @@ edition = "2021" anyhow = "1.0.69" async-graphql-parser = "^2.11.3" itertools = "0.10.5" -lazy_static = "1.4.0" +once_cell = "1.17" maplit = "1.0.2" ron = "0.8.0" serde = { version = "1.0.163", features = ["derive"] }