-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add a select field on HTTP and gRPC (#2962)
Co-authored-by: Tushar Mathur <tusharmath@gmail.com>
- Loading branch information
1 parent
5f667fb
commit 44777af
Showing
15 changed files
with
353 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use serde_json::Value; | ||
|
||
use crate::core::blueprint::DynamicValue; | ||
use crate::core::ir::model::IR; | ||
use crate::core::valid::Valid; | ||
|
||
pub fn apply_select(input: (IR, &Option<Value>)) -> Valid<IR, String> { | ||
let (mut ir, select) = input; | ||
|
||
if let Some(select_value) = select { | ||
let dynamic_value = match DynamicValue::try_from(select_value) { | ||
Ok(dynamic_value) => dynamic_value.prepend("args"), | ||
Err(e) => { | ||
return Valid::fail_with( | ||
format!("syntax error when parsing `{:?}`", select), | ||
e.to_string(), | ||
) | ||
} | ||
}; | ||
|
||
ir = ir.pipe(IR::Dynamic(dynamic_value)); | ||
Valid::succeed(ir) | ||
} else { | ||
Valid::succeed(ir) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
source: tests/core/spec.rs | ||
expression: response | ||
--- | ||
{ | ||
"status": 200, | ||
"headers": { | ||
"content-type": "application/json" | ||
}, | ||
"body": { | ||
"data": { | ||
"userCompany": { | ||
"name": "FOO", | ||
"catchPhrase": "BAR" | ||
}, | ||
"userDetails": { | ||
"city": "FIZZ" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
44777af
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
428050 requests in 30.02s, 795.96MB read
Requests/sec: 14256.49
Transfer/sec: 26.51MB