feat: support custom-headers#455
Conversation
Codecov ReportAll modified lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #455 +/- ##
==========================================
+ Coverage 84.20% 85.94% +1.74%
==========================================
Files 50 50
Lines 4532 4554 +22
==========================================
+ Hits 3816 3914 +98
+ Misses 716 640 -76
☔ View full report in Codecov by Sentry. |
|
@tusharmath @amitksingh1490 do not able to test this? any recommendation/direction? |
|
We will need tests over here as coverage drops quite significantly. I think a little bit of refactoring of the functions can make this piece more testable without requiring mocks. Test Specifications:
|
|
Let me know if there are any other questions @wrath-of-god Feel free to hop on our discord to get more help if needed. |
c98282e to
7b5b171
Compare
|
I think this is great! We could clean this up a little bit though.
|
| @@ -0,0 +1,17 @@ | |||
| #> server-sdl | |||
| schema @server(baseURL: "https://jsonplaceholder.typicode.com", setHeaders: [{key: "🤣", value: "a"}]) { | |||
There was a problem hiding this comment.
| schema @server(baseURL: "https://jsonplaceholder.typicode.com", setHeaders: [{key: "🤣", value: "a"}]) { | |
| schema @server(baseURL: "https://jsonplaceholder.typicode.com", responseHeaders: [{key: "🤣", value: "a"}]) { |
How about calling it responseHeaders ?
|
|
||
| #> client-sdl | ||
| type Failure | ||
| @error(message: "Parsing failed because of invalid HTTP header name", trace: ["schema", "@server", "setHeaders"]) |
There was a problem hiding this comment.
- Add tests for invalid Http HeaderValue
- Add tests for multiple failures ie, if multiple headers are invalid, we should be able to show all of them in errors.
dd1b38b to
e5743cb
Compare
| pub struct Server { | ||
| pub allowed_headers: Option<HashSet<String>>, | ||
| pub base_url: Option<String>, | ||
| pub enable_apollo_tracing: Option<bool>, | ||
| pub enable_cache_control_header: Option<bool>, | ||
| pub enable_graphiql: Option<String>, | ||
| pub enable_http_cache: Option<bool>, | ||
| pub enable_introspection: Option<bool>, | ||
| pub enable_query_validation: Option<bool>, | ||
| pub enable_response_validation: Option<bool>, | ||
| pub global_response_timeout: Option<i64>, | ||
| pub port: Option<u16>, | ||
| pub upstream: Upstream, | ||
| pub vars: BTreeMap<String, String>, | ||
| pub batch: Option<crate::config::Batch>, | ||
| pub response_headers: HeaderMap, | ||
| } |
There was a problem hiding this comment.
We can drop Option The Server in blueprint should contain the final values. Which means basically no option types, HeaderMap instead of KeyValues, Urls instead of String etc. It should be safe to use blueprint::Server.
src/blueprint/from_config.rs
Outdated
|
|
||
| Valid::Ok(()) | ||
| server | ||
| } |
There was a problem hiding this comment.
Can `impl Fromconfig::Server for blueprint::Server
There was a problem hiding this comment.
This should be tryFrom and return Valid
| }, | ||
| } | ||
| } | ||
| fn validate_both<A1>(self, other: Result<A1, ValidationError<E>>) -> Valid<(A, A1), E> { |
There was a problem hiding this comment.
Did we use this function anywhere?
e5743cb to
6a9999b
Compare
|
@tusharmath Please review before conflicts come 🙏 . |
* commit '69814ec785fef5d5cf3d4ba925a4910e0a09715e': refactor: use default batch settings if group_by is used (tailcallhq#497) refactor: use blueprint server throughout (tailcallhq#495) feat: hostname config in server (tailcallhq#493) Load YAML & JSON formats via CLI (tailcallhq#467) fix(deps): update rust crate regex to 1.10.1 (tailcallhq#491) fix(deps): update rust crate async-trait to 0.1.74 (tailcallhq#492) feat: support custom-headers (tailcallhq#455) fix: n + 1 issue (tailcallhq#487) fix: mandatory file path refactor: drop key from group by (tailcallhq#484) feature: load multiple configs via CLI (tailcallhq#482) feat: merge right on config (tailcallhq#476) doc: example update fix: upstream setting keys should be optional (tailcallhq#474) refactor: prerequisite to test multi sdl (tailcallhq#475) refactor: use btreeset where duplicates are not allowed (tailcallhq#478) fix: info loss in const serialisation (tailcallhq#477) feat: support to configure http settings (tailcallhq#388)
/claim #377
fixes #377
Build & Testing:
cargo testsuccessfully../lint.shto address and fix linting issues.Checklist: