From 680e9f7a6085287943db25d0b717d699a5ab5a75 Mon Sep 17 00:00:00 2001 From: laststylebender Date: Thu, 5 Dec 2024 14:46:18 +0530 Subject: [PATCH 1/3] - skip input types for @AddField directive. --- src/core/config/transformer/flatten_single_field.rs | 7 ++++++- ..._single_field__test__type_name_generator_transform.snap | 7 ++++++- .../fixtures/configs/flatten_single_field.graphql | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/core/config/transformer/flatten_single_field.rs b/src/core/config/transformer/flatten_single_field.rs index b153ce87f9..1f8f53fdd6 100644 --- a/src/core/config/transformer/flatten_single_field.rs +++ b/src/core/config/transformer/flatten_single_field.rs @@ -58,7 +58,12 @@ impl Transform for FlattenSingleField { fn transform(&self, mut config: Self::Value) -> Valid { 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::::new(); if let Some(path) = get_single_field_path( diff --git a/src/core/config/transformer/snapshots/tailcall__core__config__transformer__flatten_single_field__test__type_name_generator_transform.snap b/src/core/config/transformer/snapshots/tailcall__core__config__transformer__flatten_single_field__test__type_name_generator_transform.snap index 90e0cd69e0..04995872b1 100644 --- a/src/core/config/transformer/snapshots/tailcall__core__config__transformer__flatten_single_field__test__type_name_generator_transform.snap +++ b/src/core/config/transformer/snapshots/tailcall__core__config__transformer__flatten_single_field__test__type_name_generator_transform.snap @@ -6,10 +6,14 @@ schema @server @upstream { query: Query } -type Bar { +input Bar { a: Int } +input Input { + a: Bar +} + type Connection { user: User } @@ -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 diff --git a/tailcall-fixtures/fixtures/configs/flatten_single_field.graphql b/tailcall-fixtures/fixtures/configs/flatten_single_field.graphql index 8eba1e7287..31db63646b 100644 --- a/tailcall-fixtures/fixtures/configs/flatten_single_field.graphql +++ b/tailcall-fixtures/fixtures/configs/flatten_single_field.graphql @@ -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 From ac5a4111452e1601036d49f056f85677bd7dcbfc Mon Sep 17 00:00:00 2001 From: laststylebender Date: Thu, 5 Dec 2024 14:47:44 +0530 Subject: [PATCH 2/3] - snap update: we don't support add field directive on input types. --- ...li__fixtures__generator__gen_json_proto_mix_config.md.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__gen_json_proto_mix_config.md.snap b/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__gen_json_proto_mix_config.md.snap index e5123e7567..3e176c6dfd 100644 --- a/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__gen_json_proto_mix_config.md.snap +++ b/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__gen_json_proto_mix_config.md.snap @@ -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 { From 794337a8b891588bdc96ff7dddb55c818b1f643c Mon Sep 17 00:00:00 2001 From: laststylebender Date: Thu, 5 Dec 2024 15:20:17 +0530 Subject: [PATCH 3/3] - snap update: we don't support @AddField directive on input types. --- ...tests__cli__fixtures__generator__proto-connect-rpc.md.snap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap b/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap index dfcf3f967f..23a4aba11f 100644 --- a/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap +++ b/tests/cli/snapshots/cli_spec__test__generator_spec__tests__cli__fixtures__generator__proto-connect-rpc.md.snap @@ -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 {