Skip to content

Commit

Permalink
fix: call operator changes list of arguments (tailcallhq#2387)
Browse files Browse the repository at this point in the history
  • Loading branch information
meskill committed Jul 9, 2024
1 parent 2681303 commit 9ca04d6
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 36 deletions.
26 changes: 2 additions & 24 deletions src/core/blueprint/operators/call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
},
)
}
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Post {
body: String!
id: Int!
title: String!
user(id: Int): User
user: User
userId: Int!
}

Expand Down
8 changes: 4 additions & 4 deletions tests/core/snapshots/call-mutation.md_client.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -72,7 +72,7 @@ scalar Url
type User {
id: Int
name: String
posts(userId: Int): [Post]
posts: [Post]
}

schema {
Expand Down
12 changes: 6 additions & 6 deletions tests/core/snapshots/call-operator.md_client.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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!
}

Expand Down Expand Up @@ -91,7 +91,7 @@ type User {
type UserWithPosts {
id: Int!
name: String!
posts(id: ID): [Post]
posts: [Post]
}

schema {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ scalar PhoneNumber
type Post {
id: Int!
title: String!
user(id: Int): User
user: User
userId: Int!
}

Expand Down

0 comments on commit 9ca04d6

Please sign in to comment.