Skip to content

Commit

Permalink
inteoduceborrowed_fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddOnTop committed Sep 12, 2024
1 parent bedc4f0 commit db8ff19
Show file tree
Hide file tree
Showing 4 changed files with 191 additions and 162 deletions.
6 changes: 5 additions & 1 deletion projects/ssddOnTop/src/http/request_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ pub async fn handle_request(
app_ctx: AppCtx,
) -> anyhow::Result<hyper::Response<Full<Bytes>>> {
let resp = match req.method {
Method::GET => hyper::Response::new(Full::new(Bytes::from_static(b"Hello, World!"))),
Method::GET => hyper::Response::builder()
.status(hyper::StatusCode::OK)
.body(Full::new(Bytes::from(async_graphql::http::GraphiQLSource::build().finish())))?,
Method::POST => handle_gql_req(req, app_ctx).await?,
_ => hyper::Response::builder()
.status(hyper::StatusCode::METHOD_NOT_ALLOWED)
Expand All @@ -39,6 +41,8 @@ async fn handle_gql_req(
let eval_ctx = EvalContext::new(&req_ctx);
let path_finder = PathFinder::new(doc, &app_ctx.blueprint);
let fields = path_finder.exec().await;
let borrowed_fields = fields.to_borrowed();

let resolved = fields.resolve(eval_ctx).await?;
let finalized = resolved.finalize();
Ok(hyper::Response::new(Full::new(Bytes::from(
Expand Down
12 changes: 0 additions & 12 deletions projects/ssddOnTop/src/ir/eval_ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ impl<'a> EvalContext<'a> {
..self
}
}
pub fn clear_args(self) -> Self {
Self {
graphql_ctx_args: None,
..self
}
}
pub fn clear_value(self) -> Self {
Self {
graphql_ctx_value: None,
..self
}
}
pub fn path_arg<T: AsRef<str>>(&self, path: &[T]) -> Option<Cow<'a, Value>> {
let args = self.graphql_ctx_args.as_ref()?;
get_path_value(args, path).map(|a| Cow::Owned(a.clone()))
Expand Down
Loading

0 comments on commit db8ff19

Please sign in to comment.