diff --git a/config.graphql b/config.graphql index eecfc11..a4c9846 100644 --- a/config.graphql +++ b/config.graphql @@ -1,5 +1,8 @@ schema - @upstream(baseURL: "http://jsonplaceholder.typicode.com") { + @upstream(baseURL: "http://jsonplaceholder.typicode.com") + @link(type: Config, src: "./user/user.graphql") + @link(type: Config, src: "./post.graphql") +{ query: Query } @@ -7,19 +10,10 @@ type Query { posts: [Post] @http(path: "/posts") } -type User { - id: Int! - name: String! - username: String! - email: String! - phone: String - website: String -} type Post { id: Int! userId: Int! title: String! body: String! - user: User @http(path: "/users/{{.value.userId}}") } diff --git a/post.graphql b/post.graphql new file mode 100644 index 0000000..e12e693 --- /dev/null +++ b/post.graphql @@ -0,0 +1,15 @@ +schema @upstream(baseURL: "http://jsonplaceholder.typicode.com") { + query: Query +} + +type Query { + post(id: Int!): Post @http(path: "/posts/{{.args.id}}") +} + +type Post { + id: Int! + userId: Int! + title: String! + body: String! + user: User @http(path: "/users/{{.value.userId}}") +} diff --git a/user/user.graphql b/user/user.graphql new file mode 100644 index 0000000..8ef48cf --- /dev/null +++ b/user/user.graphql @@ -0,0 +1,16 @@ +schema @upstream(baseURL: "http://jsonplaceholder.typicode.com") { + query: Query +} + +type Query { + user(id: Int!): User @http(path: "/users/{{.args.id}}") +} + +type User { + id: Int! + name: String! + username: String! + email: String! + phone: String + website: String +} \ No newline at end of file