diff --git a/config/schema.graphql b/config/schema.graphql new file mode 100644 index 000000000..82a2f447e --- /dev/null +++ b/config/schema.graphql @@ -0,0 +1,81 @@ +schema @server @upstream(baseURL: "https://jsonplaceholder.typicode.com") { + query: Query +} + +type Address { + city: String + geo: Geo + street: String + suite: String + zipcode: String +} + +type Company { + bs: String + catchPhrase: String + name: String +} + +type Geo { + lat: String + lng: String +} + +type Photo { + albumId: Int + id: Int + thumbnailUrl: String + title: String + url: String +} + +type Post { + body: String + id: Int + title: String + userId: Int + user: User @call(path: "/users/{{.args.userId}}") +} + +type Comment { + body: String + email: String + id: Int + name: String + postId: Int + post: Post @call(path: "/posts/{{.args.postId}}") +} + +type Query { + comment(id: Int!): Comment @http(path: "/comments/{{.args.id}}") + comments: [Comment] @http(path: "/comments") + photo(id: Int!): Photo @http(path: "/photos/{{.args.id}}") + photos: [Photo] @http(path: "/photos") + post(id: Int!): Post @http(path: "/posts/{{.args.id}}") + posts: [Post] @http(path: "/posts") + todo(id: Int!): Todo @http(path: "/todos/{{.args.id}}") + todos: [Todo] @http(path: "/todos") + user(id: Int!): User @http(path: "/users/{{.args.id}}") + users: [User] @http(path: "/users") +} + +type Todo { + completed: Boolean + id: Int + title: String + userId: Int + user: User @call(path: "/users/{{.args.userId}}") +} + +type User { + address: Address + company: Company + email: String + id: Int + name: String + phone: String + username: String + website: String + posts: [Post] @call(path: "/posts?userId={{.args.id}}") + todos: [Todo] @call(path: "/todos?userId={{.args.id}}") +} diff --git a/config/tailcall.config.json b/config/tailcall.config.json new file mode 100644 index 000000000..c6e2754ca --- /dev/null +++ b/config/tailcall.config.json @@ -0,0 +1,87 @@ +{ + "schema": "schema @server @upstream(baseURL: \"https://jsonplaceholder.typicode.com\") {\n query: Query\n}\n\ntype Address {\n city: String\n geo: Geo\n street: String\n suite: String\n zipcode: String\n}\n\ntype Company {\n bs: String\n catchPhrase: String\n name: String\n}\n\ntype Geo {\n lat: String\n lng: String\n}\n\ntype Photo {\n albumId: Int\n id: Int\n thumbnailUrl: String\n title: String\n url: String\n}\n\ntype Post {\n body: String\n id: Int\n title: String\n userId: Int\n user: User @call(path: \"/users/{{.args.userId}}\")\n}\n\ntype Comment {\n body: String\n email: String\n id: Int\n name: String\n postId: Int\n post: Post @call(path: \"/posts/{{.args.postId}}\")\n}\n\ntype Query {\n comment(id: Int!): Comment @http(path: \"/comments/{{.args.id}}\")\n comments: [Comment] @http(path: \"/comments\")\n photo(id: Int!): Photo @http(path: \"/photos/{{.args.id}}\")\n photos: [Photo] @http(path: \"/photos\")\n post(id: Int!): Post @http(path: \"/posts/{{.args.id}}\")\n posts: [Post] @http(path: \"/posts\")\n todo(id: Int!): Todo @http(path: \"/todos/{{.args.id}}\")\n todos: [Todo] @http(path: \"/todos\")\n user(id: Int!): User @http(path: \"/users/{{.args.id}}\")\n users: [User] @http(path: \"/users\")\n}\n\ntype Todo {\n completed: Boolean\n id: Int\n title: String\n userId: Int\n user: User @call(path: \"/users/{{.args.userId}}\")\n}\n\ntype User {\n address: Address\n company: Company\n email: String\n id: Int\n name: String\n phone: String\n username: String\n website: String\n posts: [Post] @call(path: \"/posts?userId={{.args.id}}\")\n todos: [Todo] @call(path: \"/todos?userId={{.args.id}}\")\n}", + "types": { + "Address": { + "city": "String", + "geo": "Geo", + "street": "String", + "suite": "String", + "zipcode": "String" + }, + "Company": { + "bs": "String", + "catchPhrase": "String", + "name": "String" + }, + "Geo": { + "lat": "String", + "lng": "String" + }, + "Photo": { + "albumId": "Int", + "id": "Int", + "thumbnailUrl": "String", + "title": "String", + "url": "String" + }, + "Post": { + "body": "String", + "id": "Int", + "title": "String", + "userId": "Int", + "user": "User" + }, + "Comment": { + "body": "String", + "email": "String", + "id": "Int", + "name": "String", + "postId": "Int", + "post": "Post" + }, + "Query": { + "comment": "Comment", + "comments": "[Comment]", + "photo": "Photo", + "photos": "[Photo]", + "post": "Post", + "posts": "[Post]", + "todo": "Todo", + "todos": "[Todo]", + "user": "User", + "users": "[User]" + }, + "Todo": { + "completed": "Boolean", + "id": "Int", + "title": "String", + "userId": "Int", + "user": "User" + }, + "User": { + "address": "Address", + "company": "Company", + "email": "String", + "id": "Int", + "name": "String", + "phone": "String", + "username": "String", + "website": "String", + "posts": "[Post]", + "todos": "[Todo]" + } + }, + "queries": { + "comment": "/comments/{{.args.id}}", + "comments": "/comments", + "photo": "/photos/{{.args.id}}", + "photos": "/photos", + "post": "/posts/{{.args.id}}", + "posts": "/posts", + "todo": "/todos/{{.args.id}}", + "todos": "/todos", + "user": "/users/{{.args.id}}", + "users": "/users" + } + } + \ No newline at end of file diff --git a/config/tailcall.config.ts b/config/tailcall.config.ts new file mode 100644 index 000000000..8fa6500a5 --- /dev/null +++ b/config/tailcall.config.ts @@ -0,0 +1,84 @@ +import { TailcallConfig } from '@tailcallhq/tailcall'; + +const config: TailcallConfig = { + schema: ` + schema @server @upstream(baseURL: "https://jsonplaceholder.typicode.com") { + query: Query + } + + type Address { + city: String + geo: Geo + street: String + suite: String + zipcode: String + } + + type Company { + bs: String + catchPhrase: String + name: String + } + + type Geo { + lat: String + lng: String + } + + type Photo { + albumId: Int + id: Int + thumbnailUrl: String + title: String + url: String + } + + type Post { + body: String + id: Int + title: String + userId: Int + } + + type Comment { + body: String + email: String + id: Int + name: String + postId: Int + } + + type Query { + comment(id: Int!): Comment @http(path: "/comments/{{.args.id}}") + comments: [Comment] @http(path: "/comments") + photo(id: Int!): Photo @http(path: "/photos/{{.args.id}}") + photos: [Photo] @http(path: "/photos") + post(id: Int!): Post @http(path: "/posts/{{.args.id}}") + posts: [Post] @http(path: "/posts") + todo(id: Int!): Todo @http(path: "/todos/{{.args.id}}") + todos: [Todo] @http(path: "/todos") + user(id: Int!): User @http(path: "/users/{{.args.id}}") + users: [User] @http(path: "/users") + } + + type Todo { + completed: Boolean + id: Int + title: String + userId: Int + } + + type User { + address: Address + company: Company + email: String + id: Int + name: String + phone: String + username: String + website: String + } + `, +}; + +export default config; diff --git a/config/tailcall.config.yml b/config/tailcall.config.yml new file mode 100644 index 000000000..f4a7eeace --- /dev/null +++ b/config/tailcall.config.yml @@ -0,0 +1,156 @@ +schema: | + schema @server @upstream(baseURL: "https://jsonplaceholder.typicode.com") { + query: Query + } + + type Address { + city: String + geo: Geo + street: String + suite: String + zipcode: String + } + + type Company { + bs: String + catchPhrase: String + name: String + } + + type Geo { + lat: String + lng: String + } + + type Photo { + albumId: Int + id: Int + thumbnailUrl: String + title: String + url: String + } + + type Post { + body: String + id: Int + title: String + userId: Int + user: User @call(path: "/users/{{.args.userId}}") + } + + type Comment { + body: String + email: String + id: Int + name: String + postId: Int + post: Post @call(path: "/posts/{{.args.postId}}") + } + + type Query { + comment(id: Int!): Comment @http(path: "/comments/{{.args.id}}") + comments: [Comment] @http(path: "/comments") + photo(id: Int!): Photo @http(path: "/photos/{{.args.id}}") + photos: [Photo] @http(path: "/photos") + post(id: Int!): Post @http(path: "/posts/{{.args.id}}") + posts: [Post] @http(path: "/posts") + todo(id: Int!): Todo @http(path: "/todos/{{.args.id}}") + todos: [Todo] @http(path: "/todos") + user(id: Int!): User @http(path: "/users/{{.args.id}}") + users: [User] @http(path: "/users") + } + + type Todo { + completed: Boolean + id: Int + title: String + userId: Int + user: User @call(path: "/users/{{.args.userId}}") + } + + type User { + address: Address + company: Company + email: String + id: Int + name: String + phone: String + username: String + website: String + posts: [Post] @call(path: "/posts?userId={{.args.id}}") + todos: [Todo] @call(path: "/todos?userId={{.args.id}}") + } + +types: + Address: + city: "String" + geo: "Geo" + street: "String" + suite: "String" + zipcode: "String" + Company: + bs: "String" + catchPhrase: "String" + name: "String" + Geo: + lat: "String" + lng: "String" + Photo: + albumId: "Int" + id: "Int" + thumbnailUrl: "String" + title: "String" + url: "String" + Post: + body: "String" + id: "Int" + title: "String" + userId: "Int" + user: "User" + Comment: + body: "String" + email: "String" + id: "Int" + name: "String" + postId: "Int" + post: "Post" + Query: + comment: "Comment" + comments: "[Comment]" + photo: "Photo" + photos: "[Photo]" + post: "Post" + posts: "[Post]" + todo: "Todo" + todos: "[Todo]" + user: "User" + users: "[User]" + Todo: + completed: "Boolean" + id: "Int" + title: "String" + userId: "Int" + user: "User" + User: + address: "Address" + company: "Company" + email: "String" + id: "Int" + name: "String" + phone: "String" + username: "String" + website: "String" + posts: "[Post]" + todos: "[Todo]" + +queries: + comment: "/comments/{{.args.id}}" + comments: "/comments" + photo: "/photos/{{.args.id}}" + photos: "/photos" + post: "/posts/{{.args.id}}" + posts: "/posts" + todo: "/todos/{{.args.id}}" + todos: "/todos" + user: "/users/{{.args.id}}" + users: "/users" diff --git a/package.json b/package.json index 7d4bed23c..bc614f115 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "format:check": "prettier --check '**/*.{graphql,yml,json,md,sh,ts,tsx,js}'", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", - "typecheck": "tsc" + "typecheck": "tsc", + "tailcall:validate": "tailcall validate --config tailcall.config.ts" }, "dependencies": { "@docusaurus/core": "3.4.0", @@ -61,6 +62,7 @@ "eslint": "^8.56.0", "prettier": "^3.3.2", "prettier-plugin-sh": "^0.14.0", + "tailcall": "^0.0.0", "typescript": "~5.5.2" }, "browserslist": { @@ -77,5 +79,6 @@ }, "engines": { "node": ">=18.0" - } + }, + "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" }