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

fix: __typename do not work at root level #2840

Merged
merged 4 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading