Skip to content

Commit

Permalink
partial
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Sep 15, 2024
1 parent 6de9e66 commit c453ad8
Show file tree
Hide file tree
Showing 20 changed files with 154 additions and 91 deletions.
3 changes: 2 additions & 1 deletion src/cli/tc/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::core::config::{Config, Expr, Field, Resolver, RootSchema, Source};
use crate::core::merge_right::MergeRight;
use crate::core::runtime::TargetRuntime;
use crate::core::{config, Type};
use crate::core::valid::Validator;

pub(super) async fn init_command(runtime: TargetRuntime, folder_path: &str) -> Result<()> {
create_directory(folder_path).await?;
Expand Down Expand Up @@ -61,7 +62,7 @@ async fn confirm_and_write_yml(
match runtime.file.read(yml_file_path.as_ref()).await {
Ok(yml_content) => {
let graphqlrc: serde_yaml::Value = serde_yaml::from_str(&yml_content)?;
final_graphqlrc = graphqlrc.merge_right(final_graphqlrc);
final_graphqlrc = graphqlrc.merge_right(final_graphqlrc).to_result()?;
let content = serde_yaml::to_string(&final_graphqlrc)?;
confirm_and_write(runtime.clone(), &yml_file_path, content.as_bytes()).await
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ pub struct Field {

// It's a terminal implementation of MergeRight
impl MergeRight for Field {
fn merge_right(self, other: Self) -> Self {
other
fn merge_right(self, other: Self) -> Valid<Self, String> {
Valid::succeed(other)
}
}

Expand Down
14 changes: 4 additions & 10 deletions src/core/config/config_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ impl From<Config> for Cache {
}

impl MergeRight for Cache {
fn merge_right(self, other: Self) -> Self {
Cache::from(self.config.merge_right(other.config))
fn merge_right(self, other: Self) -> Valid<Self, String> {
self.config.merge_right(other.config).map(Cache::from)
}
}

Expand All @@ -63,11 +63,6 @@ impl ConfigModule {
self
}

pub fn merge_extensions(mut self, extensions: Extensions) -> Self {
self.extensions = self.extensions.merge_right(extensions);
self
}

pub fn config(&self) -> &Config {
&self.cache.config
}
Expand Down Expand Up @@ -151,10 +146,9 @@ impl Extensions {
}

impl MergeRight for FileDescriptorSet {
fn merge_right(mut self, other: Self) -> Self {
fn merge_right(mut self, other: Self) -> Valid<Self, String> {
self.file.extend(other.file);

self
Valid::succeed(self)
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/config/cors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ use crate::core::http::Method;
use crate::core::is_default;

Check warning on line 5 in src/core/config/cors.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/cors.rs
use crate::core::macros::MergeRight;
use crate::core::merge_right::MergeRight;
use crate::core::valid::Valid;
use crate::core::valid::Validator;


/// Type to configure Cross-Origin Resource Sharing (CORS) for a server.
#[derive(
Expand Down
2 changes: 2 additions & 0 deletions src/core/config/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::core::config::KeyValue;
use crate::core::is_default;

Check warning on line 7 in src/core/config/headers.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/headers.rs
use crate::core::macros::MergeRight;
use crate::core::merge_right::MergeRight;
use crate::core::valid::Valid;
use crate::core::valid::Validator;

#[derive(
Serialize, Deserialize, Clone, Debug, Default, PartialEq, Eq, schemars::JsonSchema, MergeRight,
Expand Down
7 changes: 5 additions & 2 deletions src/core/config/key_values.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ use std::collections::BTreeMap;
use std::ops::Deref;

Check warning on line 3 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/key_values.rs
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use tailcall_macros::MergeRight;
use crate::core::valid::{Valid,Validator};
use crate::core::merge_right::MergeRight;

#[derive(Clone, Debug, Default, Eq, PartialEq, schemars::JsonSchema)]
#[derive(Clone, Debug, Default, Eq, PartialEq, MergeRight, schemars::JsonSchema)]

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests (WASM)

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests (Cloudflare)

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests (Cloudflare)

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests (Cloudflare)

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Test AWS Lambda Build

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Check Examples

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Check Examples

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Check Examples

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-gnu

missing field `0` in initializer of `key_values::KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-x64-musl

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-musl

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-arm64-gnu

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-arm64

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on darwin-x64

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on linux-ia32-gnu

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-x64-msvc

missing field `0` in initializer of `KeyValues`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

expected identifier, found `:`

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

proc-macro derive produced unparsable tokens

Check failure on line 9 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Tests on win32-ia32-msvc

missing field `0` in initializer of `KeyValues`
pub struct KeyValues(pub BTreeMap<String, String>);

impl Deref for KeyValues {
Expand All @@ -20,7 +23,7 @@ impl FromIterator<(String, String)> for KeyValues {
}

Check warning on line 23 in src/core/config/key_values.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/key_values.rs
}

#[derive(Serialize, Deserialize, Clone, Debug, Default, Eq, PartialEq, schemars::JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, Default, Eq, PartialEq, schemars::JsonSchema, MergeRight)]
pub struct KeyValue {
pub key: String,
pub value: String,
Expand Down
8 changes: 4 additions & 4 deletions src/core/config/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::core::proto_reader::ProtoReader;
use crate::core::resource_reader::{Cached, Resource, ResourceReader};
use crate::core::rest::EndpointSet;
use crate::core::runtime::TargetRuntime;
use crate::core::valid::Validator;

/// Reads the configuration from a file or from an HTTP URL and resolves all
/// linked extensions to create a ConfigModule.
Expand Down Expand Up @@ -69,13 +70,13 @@ impl ConfigReader {
let content = source.content;

Check warning on line 70 in src/core/config/reader.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/reader.rs

let config = Config::from_source(Source::detect(&source.path)?, &content)?;
config_module = config_module.merge_right(config.clone().into());
config_module = config_module.merge_right(config.clone().into()).to_result()?;

if !config.links.is_empty() {
let cfg_module = self
.ext_links(ConfigModule::from(config), Path::new(&link.src).parent())

Check warning on line 77 in src/core/config/reader.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/reader.rs
.await?;
config_module = config_module.merge_right(cfg_module.clone());
config_module = config_module.merge_right(cfg_module.clone()).to_result()?;
}
}
LinkType::Protobuf => {
Expand Down Expand Up @@ -183,7 +184,6 @@ impl ConfigReader {
) -> anyhow::Result<ConfigModule> {
let files = self.resource_reader.read_files(files).await?;
let mut config_module = ConfigModule::default();

for file in files.iter() {
let source = Source::detect(&file.path)?;
let schema = &file.content;
Expand All @@ -197,7 +197,7 @@ impl ConfigReader {
.await?;

// Merge it with the original config set
config_module = config_module.merge_right(new_config_module);
config_module = config_module.merge_right(new_config_module).to_result()?;
}

Ok(config_module)
Expand Down
3 changes: 3 additions & 0 deletions src/core/config/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use crate::core::config::KeyValue;
use crate::core::is_default;

Check warning on line 9 in src/core/config/server.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/server.rs
use crate::core::macros::MergeRight;
use crate::core::merge_right::MergeRight;
use crate::core::valid::Valid;
use crate::core::valid::Validator;


#[derive(
Serialize,
Expand Down
4 changes: 3 additions & 1 deletion src/core/config/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::core::macros::MergeRight;
use crate::core::merge_right::MergeRight;
use crate::core::mustache::Mustache;
use crate::core::valid::Validator;
use crate::core::valid::Valid;

mod defaults {
pub mod prometheus {
Expand Down Expand Up @@ -79,6 +80,7 @@ pub enum TelemetryExporter {
schemars::JsonSchema,
DirectiveDefinition,
InputDefinition,
MergeRight,
)]
#[directive_definition(locations = "Schema")]
#[serde(deny_unknown_fields)]
Expand All @@ -103,7 +105,7 @@ impl Telemetry {
(None, None) => None,
(None, Some(export)) => Some(export),
(Some(export), None) => Some(export.clone()),
(Some(left), Some(right)) => Some(left.clone().merge_right(right.clone())),
(Some(left), Some(right)) => left.clone().merge_right(right.clone()).to_result().ok(),
};
self.request_headers.extend(other.request_headers);

Expand Down
39 changes: 26 additions & 13 deletions src/core/config/transformer/merge_types/type_merger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,27 +196,40 @@ impl TypeMerger {

Check warning on line 196 in src/core/config/transformer/merge_types/type_merger.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/config/transformer/merge_types/type_merger.rs
fn merge_type(type_: &Type, mut merge_into: Type) -> Type {
// Merge the simple fields using `merge_right`.
merge_into.added_fields = merge_into
let mut merge_into = merge_into
.added_fields
.merge_right(type_.added_fields.clone());
merge_into.implements = merge_into.implements.merge_right(type_.implements.clone());
merge_into.cache = merge_into.cache.merge_right(type_.cache.clone());
merge_into.protected = merge_into.protected.merge_right(type_.protected.clone());
merge_into.doc = merge_into.doc.merge_right(type_.doc.clone());
.clone()
.merge_right(type_.added_fields.clone()).and_then(|fields| {
merge_into.implements.clone().merge_right(type_.implements.clone()).map(|implements| (fields, implements))
}).and_then(|(fields, implements)| {
merge_into.cache.clone().merge_right(type_.cache.clone()).map(|cache| (fields, implements, cache))
}).and_then(|(fields, implements, cache)| {
merge_into.protected.clone().merge_right(type_.protected.clone()).map(|protected| (fields, implements, cache, protected))
}).and_then(|(fields, implements, cache, protected)| {
merge_into.doc.clone().merge_right(type_.doc.clone()).map(|doc| (fields, implements, cache, protected, doc))
}).and_then(|(fields, implements, cache, protected, doc)| {
merge_into.added_fields = fields;
merge_into.implements = implements;
merge_into.cache = cache;
merge_into.protected = protected;
merge_into.doc = doc;
Valid::succeed(merge_into)
}).to_result().unwrap_or_default();

// Handle field output type merging correctly.
type_.fields.iter().for_each(|(key, new_field)| {
merge_into
.fields
.entry(key.to_owned())
.and_modify(|existing_field| {
let mut merged_field = existing_field.clone().merge_right(new_field.clone());
if existing_field.type_of.name() == &Scalar::JSON.to_string()
|| new_field.type_of.name() == &Scalar::JSON.to_string()
{
merged_field.type_of = Scalar::JSON.to_string().into();
}
*existing_field = merged_field;
existing_field.clone().merge_right(new_field.clone()).map(|mut merged_field| {
if existing_field.type_of.name() == &Scalar::JSON.to_string()
|| new_field.type_of.name() == &Scalar::JSON.to_string()
{
merged_field.type_of = Scalar::JSON.to_string().into();
}
*existing_field = merged_field;
}).to_result().unwrap_or_default();
})
.or_insert_with(|| new_field.to_owned());
});
Expand Down
2 changes: 2 additions & 0 deletions src/core/config/upstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use tailcall_macros::{DirectiveDefinition, InputDefinition};
use crate::core::is_default;
use crate::core::macros::MergeRight;
use crate::core::merge_right::MergeRight;
use crate::core::valid::Validator;
use crate::core::valid::Valid;

const DEFAULT_MAX_SIZE: usize = 100;

Expand Down
15 changes: 11 additions & 4 deletions src/core/generator/from_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ impl Transform for FromJsonGenerator<'_> {
.pipe(RenameTypes::new(rename_types.into_iter()))
.transform(config.clone())
})
.map(|configs| {
configs
.iter()
.fold(config, |acc, c| acc.merge_right(c.clone()))
.and_then(|configs| {
let mut config = Config::default();
for c in configs {
config.clone().merge_right(c).map(|c| config = c).to_result();
}

Valid::succeed(config)

// configs
// .iter()
// .fold(config, |acc, c| acc.merge_right(c.clone()))
})
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/generator/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Generator {
for input in self.inputs.iter() {
match input {
Input::Config { source, schema } => {
config = config.merge_right(Config::from_source(source.clone(), schema)?);
config = config.merge_right(Config::from_source(source.clone(), schema)?).to_result()?;
}
Input::Json {
url,
Expand All @@ -124,11 +124,11 @@ impl Generator {
.with_req_body(req_body.to_owned());

config = config
.merge_right(self.generate_from_json(&type_name_generator, &[req_sample])?);
.merge_right(self.generate_from_json(&type_name_generator, &[req_sample])?).to_result()?;
}
Input::Proto(proto_input) => {
config =
config.merge_right(self.generate_from_proto(proto_input, &self.query)?);
config.merge_right(self.generate_from_proto(proto_input, &self.query)?).to_result()?;
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/core/jit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use super::BuildError;
use crate::core::blueprint::{Blueprint, Index, QueryField};
use crate::core::counter::{Count, Counter};
use crate::core::jit::model::OperationPlan;
use crate::core::merge_right::MergeRight;
use crate::core::Type;

#[derive(PartialEq, strum_macros::Display)]
Expand Down Expand Up @@ -231,7 +230,7 @@ impl Builder {
};

fields.push(flat_field);
fields = fields.merge_right(child_fields);
fields.extend(child_fields);
} else if field_name == "__typename" {
let flat_field = Field {
id: FieldId::new(self.field_id.next()),
Expand Down
3 changes: 2 additions & 1 deletion src/core/jit/graphql_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::core::http::RequestContext;
use crate::core::jit;
use crate::core::jit::ConstValueExecutor;
use crate::core::merge_right::MergeRight;
use crate::core::valid::Validator;

#[derive(Clone)]
pub struct JITExecutor {
Expand Down Expand Up @@ -60,7 +61,7 @@ impl Executor for JITExecutor {
let async_req =
async_graphql::Request::from(jit_request).only_introspection();
let async_resp = self.app_ctx.execute(async_req).await;
jit_resp.merge_right(async_resp)
jit_resp.merge_right(async_resp).to_result().unwrap_or_default()
} else {
jit_resp
}
Expand Down
13 changes: 9 additions & 4 deletions src/core/jit/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use serde::Serialize;
use super::Positioned;
use crate::core::jit;
use crate::core::merge_right::MergeRight;
use crate::core::valid::Valid;

#[derive(Setters, Serialize)]
pub struct Response<Value, Error> {
Expand Down Expand Up @@ -35,7 +36,7 @@ impl<Value, Error> Response<Value, Error> {
}

impl MergeRight for async_graphql::Response {
fn merge_right(mut self, other: Self) -> Self {
fn merge_right(mut self, other: Self) -> Valid<Self, String> {
if let async_graphql::Value::Object(mut other_obj) = other.data {
if let async_graphql::Value::Object(self_obj) = std::mem::take(self.data.borrow_mut()) {
other_obj.extend(self_obj);
Expand All @@ -46,7 +47,7 @@ impl MergeRight for async_graphql::Response {
self.errors.extend(other.errors);
self.extensions.extend(other.extensions);

self
Valid::succeed(self)
}
}

Expand All @@ -70,6 +71,7 @@ mod test {
use super::Response;
use crate::core::jit::{self, Pos, Positioned};
use crate::core::merge_right::MergeRight;
use crate::core::valid::Validator;

#[test]
fn test_with_response() {
Expand Down Expand Up @@ -178,7 +180,10 @@ mod test {
ConstValue::from_json(serde_json::from_str(user_response).unwrap()).unwrap();
let query_response = async_graphql::Response::new(user_data);

let merged_response = introspection_response.merge_right(query_response);
let merged_response = introspection_response
.merge_right(query_response)
.to_result()
.unwrap();

insta::assert_json_snapshot!(merged_response);
}
Expand All @@ -196,7 +201,7 @@ mod test {
)];
resp2.errors.append(&mut err2);

let merged_resp = resp1.merge_right(resp2);
let merged_resp = resp1.merge_right(resp2).to_result().unwrap();
insta::assert_json_snapshot!(merged_resp);
}
}
Loading

0 comments on commit c453ad8

Please sign in to comment.