Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(jit): support introspection in JIT #2769

Merged
merged 33 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
24af819
- execute introspection request with async_graphql
laststylebender14 Aug 29, 2024
cb587db
- remove std::mem::take
laststylebender14 Aug 29, 2024
5d5c9b3
- imple merge_right for async_gql response
laststylebender14 Aug 29, 2024
221a27b
Merge branch 'main' into fix/execute-introspection-requests-with-asyn…
laststylebender14 Aug 29, 2024
f7d1d0f
- add case where introspection is executed via async graphql and actu…
laststylebender14 Aug 29, 2024
d930e07
- lint formatting changes
laststylebender14 Aug 29, 2024
dd095f6
- drop clone
laststylebender14 Aug 29, 2024
c530b0b
- include birthdate in selection set
laststylebender14 Aug 29, 2024
e2fe5a2
- removed skip test marker
laststylebender14 Aug 29, 2024
3d908db
- utilise executable doc to figure out if query is of introspection.
laststylebender14 Aug 29, 2024
0285f69
- added case where introspection query present in selection set but i…
laststylebender14 Aug 29, 2024
278f179
- rename test
laststylebender14 Aug 29, 2024
7aa3b46
- deleting snaps: changed name of test
laststylebender14 Aug 29, 2024
295aad7
- skipping __typename as it's implemented in JIT
laststylebender14 Aug 29, 2024
ade7145
Merge branch 'main' into fix/execute-introspection-requests-with-asyn…
laststylebender14 Aug 29, 2024
358a20a
- added test for merging async responses
laststylebender14 Aug 29, 2024
da62b03
- added test for merging of errors
laststylebender14 Aug 29, 2024
ae11ff3
- lint changes
laststylebender14 Aug 29, 2024
28ad6ef
- added snap
laststylebender14 Aug 29, 2024
948d8ab
Merge branch 'main' into fix/execute-introspection-requests-with-asyn…
laststylebender14 Aug 29, 2024
2154995
- drop method, use make field public
laststylebender14 Aug 29, 2024
3b8f1b2
- revert: clone request outside.
laststylebender14 Aug 29, 2024
a9f5463
- compute is_introspection_query separately.
laststylebender14 Aug 29, 2024
080ea31
- lint changes
laststylebender14 Aug 29, 2024
f167043
- remove duplicate cloning
laststylebender14 Aug 29, 2024
0d86e00
Merge branch 'main' into fix/execute-introspection-requests-with-asyn…
laststylebender14 Aug 29, 2024
949df8c
inline function
tusharmath Aug 29, 2024
b6a6a26
- drop un-used method.
laststylebender14 Aug 29, 2024
4a2783e
- lint changes
laststylebender14 Aug 29, 2024
96c1969
use lift to implement clone
tusharmath Aug 29, 2024
c61b17c
- avoid cloning when unnecessary
laststylebender14 Aug 29, 2024
5eba36e
- allow dead code for lift
laststylebender14 Aug 29, 2024
5cf9433
Merge branch 'main' into fix/execute-introspection-requests-with-asyn…
tusharmath Aug 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
use lift to implement clone
  • Loading branch information
tusharmath committed Aug 29, 2024
commit 96c19693c9a1ff19626836b3e04d7865dd01c47c
20 changes: 12 additions & 8 deletions src/core/jit/graphql_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use crate::core::http::RequestContext;
use crate::core::jit;
use crate::core::jit::ConstValueExecutor;
use crate::core::lift::{CanLift, Lift};
use crate::core::merge_right::MergeRight;

#[derive(Clone)]
Expand All @@ -22,20 +23,23 @@
}
}

fn clone_request(req: &async_graphql::Request) -> async_graphql::Request {
let mut request = async_graphql::Request::new(req.query.clone());
request.variables = req.variables.clone();
request.extensions = req.extensions.clone();
request.operation_name = req.operation_name.clone();
request
impl Clone for Lift<async_graphql::Request> {
fn clone(&self) -> Self {
let mut request = async_graphql::Request::new(self.query.clone());
request.variables = self.variables.clone();
request.extensions = self.extensions.clone();
request.operation_name = self.operation_name.clone();
request.into()
}
}

impl Executor for JITExecutor {
fn execute(&self, request: async_graphql::Request) -> impl Future<Output = Response> + Send {
let jit_request = jit::Request::from(clone_request(&request));
let request = request.lift();
let jit_request = jit::Request::from(request.clone().take());
tusharmath marked this conversation as resolved.
Show resolved Hide resolved

// execute only introspection requests with async graphql.
let introspection_req = request.only_introspection();
let introspection_req = request.take().only_introspection();

async {
match ConstValueExecutor::new(&jit_request, self.app_ctx.clone()) {
Expand All @@ -46,12 +50,12 @@

let jit_resp = exec
.execute(&self.req_ctx, jit_request)
.await

Check warning on line 53 in src/core/jit/graphql_executor.rs

View check run for this annotation

Codecov / codecov/patch

src/core/jit/graphql_executor.rs#L53

Added line #L53 was not covered by tests
.into_async_graphql();

if is_introspection_query {
let async_resp = self.app_ctx.execute(introspection_req).await;
jit_resp.merge_right(async_resp)

Check warning on line 58 in src/core/jit/graphql_executor.rs

View check run for this annotation

Codecov / codecov/patch

src/core/jit/graphql_executor.rs#L57-L58

Added lines #L57 - L58 were not covered by tests
} else {
jit_resp
}
Expand Down
13 changes: 11 additions & 2 deletions src/core/lift.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::ops::Deref;

Check warning on line 1 in src/core/lift.rs

View workflow job for this annotation

GitHub Actions / Run Formatter and Lint Check

Diff in /home/runner/work/tailcall/tailcall/src/core/lift.rs

///
/// Just an empty wrapper around a value used to implement `From` for foreign
/// Just an empty wrapper around a value used to implement foreign traits for foreign
/// types.
pub struct Lift<A>(A);
impl<A> Deref for Lift<A> {
Expand All @@ -12,7 +12,6 @@
}

impl<A> Lift<A> {
#[allow(dead_code)]
pub fn take(self) -> A {
self.0
}
Expand All @@ -23,3 +22,13 @@
Lift(a)
}
}

pub trait CanLift: Sized {
fn lift(self) -> Lift<Self>;
}

impl<A> CanLift for A {
fn lift(self) -> Lift<Self> {
Lift::from(self)
}
}
Loading