diff --git a/projects/tailcallhq/run.sh b/projects/tailcallhq/run.sh new file mode 100755 index 0000000..066d38c --- /dev/null +++ b/projects/tailcallhq/run.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +set -e + +npm install -g @tailcallhq/tailcall + +# Get the directory of the script +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# Set the path to the schema file relative to the script location +SCHEMA_FILE="${SCRIPT_DIR}/tailcall.graphql" + +echo "Starting the server" + +# Start Tailcall +TAILCALL_LOG_LEVEL=error TC_TRACKER=false tailcall start "${SCHEMA_FILE}" diff --git a/projects/tailcallhq/tailcall.graphql b/projects/tailcallhq/tailcall.graphql new file mode 100644 index 0000000..b44085f --- /dev/null +++ b/projects/tailcallhq/tailcall.graphql @@ -0,0 +1,45 @@ +schema + @server(port: 8000, dedupe: true) + @upstream(baseURL: "http://localhost:3000", batch: {delay: 1}) { + query: Query +} + +type Query { + posts: [Post] @http(path: "/posts") + post(id: Int!): Post @http(path: "/posts/{{.args.id}}") + users: [User] @http(path: "/users") + user(id: Int!): User @http(path: "/users/{{.args.id}}") +} + +type Post { + id: Int + userId: Int! + title: String + body: String + user: User + @http( + path: "/users" + query: [{key: "id", value: "{{.value.userId}}"}] + batchKey: ["id"] + ) +} + +type User { + id: Int + name: String + username: String + email: String + address: Address + phone: String + website: String +} + +type Address { + zipcode: String + geo: Geo +} + +type Geo { + lat: Float + lng: Float +}