Skip to content

Commit

Permalink
fix: remove support of @AddField directive on input types. (#3199)
Browse files Browse the repository at this point in the history
  • Loading branch information
laststylebender14 authored Dec 5, 2024
1 parent 51ebc1f commit 23223b8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 6 deletions.
7 changes: 6 additions & 1 deletion src/core/config/transformer/flatten_single_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ impl Transform for FlattenSingleField {
fn transform(&self, mut config: Self::Value) -> Valid<Self::Value, Self::Error> {
let origin_config = config.clone();

for ty in config.types.values_mut() {
let input_types = config.input_types();

for (ty_name, ty) in config.types.iter_mut() {
if input_types.contains(ty_name) {
continue;
}
for (field_name, field) in ty.fields.iter_mut() {
let mut visited_types = HashSet::<String>::new();
if let Some(path) = get_single_field_path(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ schema @server @upstream {
query: Query
}

type Bar {
input Bar {
a: Int
}

input Input {
a: Bar
}

type Connection {
user: User
}
Expand All @@ -28,6 +32,7 @@ type NotSingleMiddle {
}

type Query @addField(name: "foo", path: ["foo", "bar", "a"]) {
a(input: Input!): Empty
foo: Foo @omit
not_single: NotSingle
not_single_middle: NotSingleMiddle
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@ schema {
query: Query
}

input Input {
a: Bar
}

type Query {
foo: Foo
not_single: NotSingle
not_single_middle: NotSingleMiddle
user: User
a(input: Input!): Empty
}

# Type with only one field
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ schema @server @upstream {
query: Query
}

input GEN__news__MultipleNewsId @addField(name: "ids", path: ["ids", "id"]) {
ids: [Id]@omit
input GEN__news__MultipleNewsId {
ids: [Id]
}

input GEN__news__NewsInput {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ schema @server @upstream {
query: Query
}

input GEN__news__MultipleNewsId @addField(name: "ids", path: ["ids", "id"]) {
ids: [Id]@omit
input GEN__news__MultipleNewsId {
ids: [Id]
}

input GEN__news__NewsInput {
Expand Down

1 comment on commit 23223b8

@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 4.08ms 1.98ms 29.09ms 79.49%
Req/Sec 6.31k 0.91k 9.17k 91.83%

753858 requests in 30.02s, 3.78GB read

Requests/sec: 25112.12

Transfer/sec: 128.89MB

Please sign in to comment.