Skip to content

Commit

Permalink
- added test case for list edge case.
Browse files Browse the repository at this point in the history
  • Loading branch information
laststylebender14 authored and amitksingh1490 committed Jun 21, 2024
1 parent bbd1031 commit d691ada
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
source: src/core/config/transformer/type_merger/type_merger.rs
expression: config.to_sdl()
---
schema @server(hostname: "0.0.0.0", port: 8000) @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) {
query: Query
}

type F2 {
user: [User]
}

type F3 {
user: User
}

type Query {
user(id: Int!): F3 @http(path: "/users/{{.args.id}}")
users: F2 @http(path: "/users")
}

type User {
email: String!
id: Int!
name: String!
phone: String
username: String!
}
8 changes: 8 additions & 0 deletions src/core/config/transformer/type_merger/type_merger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,4 +316,12 @@ mod test {
let config = TypeMerger::default().transform(config).to_result().unwrap();
insta::assert_snapshot!(config.to_sdl());
}

#[test]
fn test_list_field_types() {
let sdl = std::fs::read_to_string(tailcall_fixtures::configs::USER_LIST).unwrap();
let config = Config::from_sdl(&sdl).to_result().unwrap();
let config = TypeMerger::default().transform(config).to_result().unwrap();
insta::assert_snapshot!(config.to_sdl());
}
}
26 changes: 26 additions & 0 deletions tailcall-fixtures/fixtures/configs/user-list.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
schema
@server(port: 8000, hostname: "0.0.0.0")
@upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) {
query: Query
}

type F2 {
user: [User]
}

type F3 {
user: User
}

type User {
id: Int!
name: String!
username: String!
email: String!
phone: String
}

type Query {
users: F2 @http(path: "/users")
user(id: Int!): F3 @http(path: "/users/{{.args.id}}")
}

0 comments on commit d691ada

Please sign in to comment.