Skip to content

Commit 4cefe05

Browse files
authored
chore: migrate to serde_yaml_ng instead of serde_yaml (#3178)
1 parent e84583d commit 4cefe05

File tree

9 files changed

+23
-27
lines changed

9 files changed

+23
-27
lines changed

Cargo.lock

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ thiserror = { workspace = true }
7474
serde_json = { workspace = true }
7575
serde = { workspace = true }
7676
serde_qs = "0.13"
77-
serde_yaml = "0.9.34"
77+
serde_yaml_ng = "0.10.0"
7878
serde_urlencoded = "0.7.1"
7979
url = { workspace = true }
8080
indexmap = { workspace = true }

src/cli/generator/generator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Generator {
8383

8484
let config: Config = match source {
8585
ConfigSource::Json => serde_json::from_str(&config_content)?,
86-
ConfigSource::Yml => serde_yaml::from_str(&config_content)?,
86+
ConfigSource::Yml => serde_yaml_ng::from_str(&config_content)?,
8787
};
8888

8989
config.into_resolved(config_path)

src/cli/tc/init.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ pub(super) async fn init_command(runtime: TargetRuntime, folder_path: &str) -> R
5555
Ok(())
5656
}
5757

58-
fn default_graphqlrc() -> serde_yaml::Value {
59-
serde_yaml::Value::Mapping(serde_yaml::mapping::Mapping::from_iter([(
58+
fn default_graphqlrc() -> serde_yaml_ng::Value {
59+
serde_yaml_ng::Value::Mapping(serde_yaml_ng::mapping::Mapping::from_iter([(
6060
"schema".into(),
61-
serde_yaml::Value::Sequence(vec!["./.tailcallrc.graphql".into(), "./*.graphql".into()]),
61+
serde_yaml_ng::Value::Sequence(vec!["./.tailcallrc.graphql".into(), "./*.graphql".into()]),
6262
)]))
6363
}
6464

@@ -72,13 +72,13 @@ async fn confirm_and_write_yml(
7272

7373
match runtime.file.read(yml_file_path.as_ref()).await {
7474
Ok(yml_content) => {
75-
let graphqlrc: serde_yaml::Value = serde_yaml::from_str(&yml_content)?;
75+
let graphqlrc: serde_yaml_ng::Value = serde_yaml_ng::from_str(&yml_content)?;
7676
final_graphqlrc = graphqlrc.merge_right(final_graphqlrc);
77-
let content = serde_yaml::to_string(&final_graphqlrc)?;
77+
let content = serde_yaml_ng::to_string(&final_graphqlrc)?;
7878
confirm_and_write(runtime.clone(), &yml_file_path, content.as_bytes()).await
7979
}
8080
Err(_) => {
81-
let content = serde_yaml::to_string(&final_graphqlrc)?;
81+
let content = serde_yaml_ng::to_string(&final_graphqlrc)?;
8282
runtime.file.write(&yml_file_path, content.as_bytes()).await
8383
}
8484
}

src/core/blueprint/operators/resolver.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,9 @@ pub fn compile_resolver(
2121
let CompileResolver { config_module, field, operation_type, object_name } = inputs;
2222

2323
match resolver {
24-
Resolver::Http(http) => compile_http(
25-
config_module,
26-
http,
27-
// inner resolver should resolve only single instance of type, not a list
28-
field,
29-
)
30-
.trace(config::Http::trace_name().as_str()),
24+
Resolver::Http(http) => {
25+
compile_http(config_module, http, field).trace(config::Http::trace_name().as_str())
26+
}
3127
Resolver::Grpc(grpc) => compile_grpc(super::CompileGrpc {
3228
config_module,
3329
operation_type,

src/core/config/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl Config {
387387
}
388388

389389
pub fn to_yaml(&self) -> Result<String> {
390-
Ok(serde_yaml::to_string(self)?)
390+
Ok(serde_yaml_ng::to_string(self)?)
391391
}
392392

393393
pub fn to_json(&self, pretty: bool) -> Result<String> {
@@ -428,7 +428,7 @@ impl Config {
428428
}
429429

430430
pub fn from_yaml(yaml: &str) -> Result<Self> {
431-
Ok(serde_yaml::from_str(yaml)?)
431+
Ok(serde_yaml_ng::from_str(yaml)?)
432432
}
433433

434434
pub fn from_sdl(sdl: &str) -> Valid<Self, String> {

src/core/merge_right.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ impl MergeRight for async_graphql_value::ConstValue {
128128
}
129129
}
130130

131-
impl MergeRight for serde_yaml::Value {
131+
impl MergeRight for serde_yaml_ng::Value {
132132
fn merge_right(self, other: Self) -> Self {
133-
use serde_yaml::Value;
133+
use serde_yaml_ng::Value;
134134

135135
match (self, other) {
136136
(Value::Null | Value::Bool(_) | Value::Number(_) | Value::String(_), other) => other,

tests/cli/parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl ExecutionSpec {
106106
"env" => {
107107
let vars: HashMap<String, String> = match source {
108108
Source::Json => Ok(serde_json::from_str(&content)?),
109-
Source::Yml => Ok(serde_yaml::from_str(&content)?),
109+
Source::Yml => Ok(serde_yaml_ng::from_str(&content)?),
110110
_ => Err(anyhow!("Unexpected language in env block in {:?} (only JSON and YAML are supported)", path)),
111111
}?;
112112

tests/core/parse.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl ExecutionSpec {
179179
if mock.is_none() {
180180
mock = match source {
181181
Source::Json => Ok(serde_json::from_str(&content)?),
182-
Source::Yml => Ok(serde_yaml::from_str(&content)?),
182+
Source::Yml => Ok(serde_yaml_ng::from_str(&content)?),
183183
_ => Err(anyhow!("Unexpected language in mock block in {:?} (only JSON and YAML are supported)", path)),
184184
}?;
185185
} else {
@@ -190,7 +190,7 @@ impl ExecutionSpec {
190190
if env.is_none() {
191191
env = match source {
192192
Source::Json => Ok(serde_json::from_str(&content)?),
193-
Source::Yml => Ok(serde_yaml::from_str(&content)?),
193+
Source::Yml => Ok(serde_yaml_ng::from_str(&content)?),
194194
_ => Err(anyhow!("Unexpected language in env block in {:?} (only JSON and YAML are supported)", path)),
195195
}?;
196196
} else {
@@ -201,7 +201,7 @@ impl ExecutionSpec {
201201
if test.is_none() {
202202
test = match source {
203203
Source::Json => Ok(serde_json::from_str(&content)?),
204-
Source::Yml => Ok(serde_yaml::from_str(&content)?),
204+
Source::Yml => Ok(serde_yaml_ng::from_str(&content)?),
205205
_ => Err(anyhow!("Unexpected language in test block in {:?} (only JSON and YAML are supported)", path)),
206206
}?;
207207
} else {

0 commit comments

Comments
 (0)