From 9ca04d6949fff426cf5c3e23037627023146f425 Mon Sep 17 00:00:00 2001 From: Kiryl Mialeshka <8974488+meskill@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:08:33 +0200 Subject: [PATCH] fix: call operator changes list of arguments (#2387) --- src/core/blueprint/operators/call.rs | 26 ++----------------- .../call-graphql-datasource.md_client.snap | 2 +- .../snapshots/call-mutation.md_client.snap | 8 +++--- .../snapshots/call-operator.md_client.snap | 12 ++++----- .../jsonplaceholder-call-post.md_client.snap | 2 +- 5 files changed, 14 insertions(+), 36 deletions(-) diff --git a/src/core/blueprint/operators/call.rs b/src/core/blueprint/operators/call.rs index 0763cfb697..d820eb3e19 100644 --- a/src/core/blueprint/operators/call.rs +++ b/src/core/blueprint/operators/call.rs @@ -18,29 +18,8 @@ pub fn update_call<'a>( return Valid::succeed(b_field); }; - compile_call(config, calls, operation_type, object_name).map(|field| { - let args = field - .args - .into_iter() - .map(|mut arg_field| { - arg_field.of_type = match &arg_field.of_type { - Type::NamedType { name, .. } => { - Type::NamedType { name: name.to_owned(), non_null: false } - } - Type::ListType { of_type, .. } => { - Type::ListType { of_type: of_type.to_owned(), non_null: false } - } - }; - - arg_field - }) - .collect(); - - b_field - .args(args) - .resolver(field.resolver) - .name(name.to_string()) - }) + compile_call(config, calls, operation_type, object_name) + .map(|field| b_field.resolver(field.resolver).name(name.to_string())) }, ) } @@ -114,7 +93,6 @@ fn compile_call( Valid::from_option( b_fields.into_iter().reduce(|mut b_field, b_field_next| { b_field.name = b_field_next.name; - b_field.args.extend(b_field_next.args); b_field.of_type = b_field_next.of_type; b_field.map_expr(|expr| { b_field_next diff --git a/tests/core/snapshots/call-graphql-datasource.md_client.snap b/tests/core/snapshots/call-graphql-datasource.md_client.snap index 308bea1215..35c677f833 100644 --- a/tests/core/snapshots/call-graphql-datasource.md_client.snap +++ b/tests/core/snapshots/call-graphql-datasource.md_client.snap @@ -28,7 +28,7 @@ type Post { body: String! id: Int! title: String! - user(id: Int): User + user: User userId: Int! } diff --git a/tests/core/snapshots/call-mutation.md_client.snap b/tests/core/snapshots/call-mutation.md_client.snap index 603b2346f5..3026469d46 100644 --- a/tests/core/snapshots/call-mutation.md_client.snap +++ b/tests/core/snapshots/call-mutation.md_client.snap @@ -23,11 +23,11 @@ scalar Int8 scalar JSON type Mutation { - attachPostToFirstUser(postId: Int, userId: Int): User + attachPostToFirstUser(postId: Int!): User attachPostToUser(postId: Int!, userId: Int!): User - insertMockedPost(input: PostInput): Post + insertMockedPost: Post insertPost(input: PostInput): Post - insertPostToFirstUser(input: PostInputWithoutUserId, userId: Int): Post + insertPostToFirstUser(input: PostInputWithoutUserId): Post insertPostToUser(input: PostInputWithoutUserId!, userId: Int!): Post } @@ -72,7 +72,7 @@ scalar Url type User { id: Int name: String - posts(userId: Int): [Post] + posts: [Post] } schema { diff --git a/tests/core/snapshots/call-operator.md_client.snap b/tests/core/snapshots/call-operator.md_client.snap index fabc494e7a..8d8f07de41 100644 --- a/tests/core/snapshots/call-operator.md_client.snap +++ b/tests/core/snapshots/call-operator.md_client.snap @@ -41,13 +41,13 @@ type Post { news: NewsData! newsWithPortArg: NewsData! title: String - user(id: Int): User + user: User user1: User userFromValue: User - userGraphQL(id: Int): User - userGraphQLHeaders(id: Int): User - userHttpHeaders(id: ID): User - userHttpQuery(id: ID): User + userGraphQL: User + userGraphQLHeaders: User + userHttpHeaders: User + userHttpQuery: User userId: Int! } @@ -91,7 +91,7 @@ type User { type UserWithPosts { id: Int! name: String! - posts(id: ID): [Post] + posts: [Post] } schema { diff --git a/tests/core/snapshots/jsonplaceholder-call-post.md_client.snap b/tests/core/snapshots/jsonplaceholder-call-post.md_client.snap index 9f2b5df9c8..bbe0dcc237 100644 --- a/tests/core/snapshots/jsonplaceholder-call-post.md_client.snap +++ b/tests/core/snapshots/jsonplaceholder-call-post.md_client.snap @@ -27,7 +27,7 @@ scalar PhoneNumber type Post { id: Int! title: String! - user(id: Int): User + user: User userId: Int! }