Skip to content

Commit

Permalink
fix: __typename do not work at root level (#2840)
Browse files Browse the repository at this point in the history
Co-authored-by: Tushar Mathur <[email protected]>
  • Loading branch information
ssddOnTop and tusharmath authored Sep 24, 2024
1 parent 69f291e commit b0bcfcf
Show file tree
Hide file tree
Showing 5 changed files with 643 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/core/jit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ impl Builder {
});

let plan = OperationPlan::new(
name,
fields,
operation.ty,
self.index.clone(),
Expand Down
1 change: 1 addition & 0 deletions src/core/jit/input_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ where
.collect::<Result<Vec<_>, _>>()?;

Ok(OperationPlan::new(
self.plan.root_name(),
new_fields,
self.plan.operation_type(),
self.plan.index.clone(),
Expand Down
10 changes: 10 additions & 0 deletions src/core/jit/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ pub struct Nested<Input>(Vec<Field<Nested<Input>, Input>>);

#[derive(Clone)]
pub struct OperationPlan<Input> {
root_name: String,
flat: Vec<Field<Flat, Input>>,
operation_type: OperationType,
nested: Vec<Field<Nested<Input>, Input>>,
Expand Down Expand Up @@ -379,6 +380,7 @@ impl<Input> OperationPlan<Input> {
}

Ok(OperationPlan {
root_name: self.root_name,
flat,
operation_type: self.operation_type,
nested,
Expand All @@ -389,7 +391,9 @@ impl<Input> OperationPlan<Input> {
}

impl<Input> OperationPlan<Input> {
#[allow(clippy::too_many_arguments)]
pub fn new(
root_name: &str,
fields: Vec<Field<Flat, Input>>,
operation_type: OperationType,
index: Arc<Index>,
Expand All @@ -406,6 +410,7 @@ impl<Input> OperationPlan<Input> {
.collect::<Vec<_>>();

Self {
root_name: root_name.to_string(),
flat: fields,
nested,
operation_type,
Expand All @@ -414,6 +419,11 @@ impl<Input> OperationPlan<Input> {
}
}

/// Returns the name of the root type
pub fn root_name(&self) -> &str {
&self.root_name
}

/// Returns a graphQL operation type
pub fn operation_type(&self) -> OperationType {
self.operation_type
Expand Down
Loading

1 comment on commit b0bcfcf

@github-actions
Copy link

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

Thread Stats Avg Stdev Max +/- Stdev
Latency 11.63ms 4.35ms 120.64ms 85.38%
Req/Sec 2.18k 241.77 2.77k 85.33%

260467 requests in 30.04s, 1.31GB read

Requests/sec: 8671.54

Transfer/sec: 44.51MB

Please sign in to comment.