Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: migrate examples to runtime config #3231

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions examples/apollo-tracing.graphql

This file was deleted.

14 changes: 14 additions & 0 deletions examples/apollo-tracing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000
hostname: "0.0.0.0"

telemetry:
export:
apollo:
apiKey: "1234"
graphRef: "abc@123"

links:
- src: ./jsonplaceholder.graphql
4 changes: 0 additions & 4 deletions examples/apollo_federation_subgraph_post.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
schema @server(port: 8001, enableFederation: true) @upstream(httpCache: 42, batch: {delay: 100}) {
query: Query
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}
Expand Down
13 changes: 13 additions & 0 deletions examples/apollo_federation_subgraph_post.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8001
enableFederation: true

upstream:
batch:
delay: 100
httpCache: 42

links:
- src: ./apollo_federation_subgraph_post.graphql
4 changes: 0 additions & 4 deletions examples/apollo_federation_subgraph_user.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
schema @server(port: 8002, enableFederation: true) @upstream(httpCache: 42, batch: {delay: 100}) {
query: Query
}

type Query {
user(id: Int!): User @http(url: "http://jsonplaceholder.typicode.com/users/{{.args.id}}")
}
Expand Down
13 changes: 13 additions & 0 deletions examples/apollo_federation_subgraph_user.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8002
enableFederation: true

upstream:
batch:
delay: 100
httpCache: 42

links:
- src: ./apollo_federation_subgraph_user.graphql
9 changes: 0 additions & 9 deletions examples/auth.graphql
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
schema
@server(port: 8000)
@upstream(httpCache: 42)
@link(id: "auth-basic", type: Htpasswd, src: ".htpasswd")
@link(id: "auth-jwt", type: Jwks, src: ".jwks") {
query: Query
mutation: Mutation
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
user(id: Int!): User @http(url: "http://jsonplaceholder.typicode.com/users/{{.args.id}}")
Expand Down
16 changes: 16 additions & 0 deletions examples/auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000

upstream:
httpCache: 42

links:
- src: ./auth.graphql
- type: Htpasswd
id: auth-basic
src: .htpasswd
- type: Jwks
id: auth-jwt
src: .jwks
4 changes: 4 additions & 0 deletions examples/call.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

links:
- src: ./call.graphql
19 changes: 0 additions & 19 deletions examples/cors.graphql

This file was deleted.

18 changes: 18 additions & 0 deletions examples/cors.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000
hostname: "0.0.0.0"
headers:
cors:
allowOrigins:
- "*"
allowHeaders:
- "*"
allowMethods:
- POST
- GET
- OPTIONS

links:
- src: ./jsonplaceholder.graphql
3 changes: 0 additions & 3 deletions examples/empty-to-jsonplaceholder.graphql

This file was deleted.

6 changes: 1 addition & 5 deletions examples/graphql-composition.graphql
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
# To run this example first start another tailcall server with basic example
# i.e. `tc start examples/jsonplaceholder.graphql`
# i.e. `tc start examples/jsonplaceholder.yaml`
# and then you can run this example and test it on 8001 port

schema @server(port: 8001, queryValidation: false, hostname: "0.0.0.0") @upstream(httpCache: 42, batch: {delay: 1}) {
query: Query
}

type Query {
posts: [Post] @graphQL(url: "http://jsonplaceholder.typicode.com", name: "posts")
}
Expand Down
14 changes: 14 additions & 0 deletions examples/graphql-composition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8001
queryValidation: false
hostname: "0.0.0.0"

upstream:
httpCache: 42
batch:
delay: 1

links:
- src: ./graphql-composition.graphql
42 changes: 0 additions & 42 deletions examples/grpc-reflection.graphql

This file was deleted.

19 changes: 19 additions & 0 deletions examples/grpc-reflection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000

upstream:
httpCache: 42
batch:
delay:
10

links:
- src: ./grpc.graphql
- type: Grpc
# for test upstream server see [repo](https://github.com/tailcallhq/tailcall/tree/main/tailcall-upstream-grpc)
src: http://localhost:50051
headers:
- key: authorization
value: Bearer 123
12 changes: 2 additions & 10 deletions examples/grpc.graphql
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
# for test upstream server see [repo](https://github.com/tailcallhq/rust-grpc)
schema
@server(port: 8000)
@upstream(httpCache: 42, batch: {delay: 10})
@link(id: "news", src: "../tailcall-fixtures/fixtures/protobuf/news.proto", type: Protobuf) {
query: Query
}

type Query {
news: NewsData! @grpc(url: "http://localhost:50051", method: "news.NewsService.GetAllNews")
newsById(news: NewsInput!): News!
@grpc(url: "http://localhost:50051", method: "news.NewsService.GetNews", body: "{{.args.news}}")
@grpc(url: "http://localhost:50051", method: "news.NewsService.GetNews", body: "{{args.news}}")
newsByIdBatch(news: NewsInput!): News!
@grpc(
url: "http://localhost:50051"
method: "news.NewsService.GetMultipleNews"
body: "{{.args.news}}"
body: "{{args.news}}"
batchKey: ["news", "id"]
)
}
Expand Down
16 changes: 16 additions & 0 deletions examples/grpc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000

upstream:
httpCache: 42
batch:
delay: 10

links:
- src: grpc.graphql
# for test upstream server see [repo](https://github.com/tailcallhq/rust-grpc)
- type: Protobuf
id: news
src: "../tailcall-fixtures/fixtures/protobuf/news.proto"
4 changes: 0 additions & 4 deletions examples/jsonplaceholder.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
schema @server(port: 8000) @upstream(httpCache: 42, batch: {delay: 100}) {
query: Query
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
users: [User] @http(url: "http://jsonplaceholder.typicode.com/users")
Expand Down
2 changes: 1 addition & 1 deletion examples/jsonplaceholder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ upstream:
httpCache: 42

links:
- src: ./jsonplaceholder.graphql
- src: jsonplaceholder.graphql
4 changes: 0 additions & 4 deletions examples/jsonplaceholder_batch.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
schema @server(port: 8000) @upstream(httpCache: 42, batch: {delay: 1, maxSize: 1000}) {
query: Query
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}
Expand Down
13 changes: 13 additions & 0 deletions examples/jsonplaceholder_batch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000

upstream:
batch:
delay: 1
maxSize: 1000
httpCache: 42

links:
- src: jsonplaceholder_batch.graphql
8 changes: 0 additions & 8 deletions examples/jsonplaceholder_http_2.graphql
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
schema
@server(port: 3000, queryValidation: false, hostname: "0.0.0.0", version: HTTP2)
@link(type: Cert, src: "./example.crt")
@link(type: Key, src: "./example.key")
@upstream(httpCache: 42) {
query: Query
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
}
Expand Down
17 changes: 17 additions & 0 deletions examples/jsonplaceholder_http_2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 3000
queryValidation: false
hostname: "0.0.0.0"
version: HTTP2

upstream:
httpCache: 42

links:
- src: ./jsonplaceholder_http_2.graphql
- type: Cert
src: ./example.crt
- type: Key
src: ./example.key
7 changes: 0 additions & 7 deletions examples/jsonplaceholder_script.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
schema
@server(port: 8000, hostname: "0.0.0.0")
@upstream(httpCache: 42, onRequest: "onRequest")
@link(type: Script, src: "scripts/echo.js") {
query: Query
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts", onResponseBody: "onResponse")
user(id: Int!): User
Expand Down
13 changes: 13 additions & 0 deletions examples/jsonplaceholder_script.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# yaml-language-server: $schema=../generated/.tailcallrc.schema.json

server:
port: 8000
hostname: "0.0.0.0"

upstream:
httpCache: 42

links:
- src: ./jsonplaceholder_script.graphql
- type: Script
src: scripts/echo.js
8 changes: 5 additions & 3 deletions examples/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ error_exit() {
check_files() {
local path="./examples"
local depth=1
local -a extensions=("-name" "*.json" -o "-name" "*.yml" -o "-name" "*.yaml" -o "-name" "*.graphql" -o "-name" "*.gql")
local command="./target/debug/tailcall check"
local -a ignore=("!" "-name" "grpc-reflection.graphql" "!" "-name" "generate.yml")
local -a extensions=("-name" "*.json" -o "-name" "*.yml" -o "-name" "*.yaml")
local command="cargo run -- check"
# ignore grpc-reflection because it requires a running grpc server
# ignore generate.yaml because it's used for generation and not service commands
local -a ignore=("!" "-name" "grpc-reflection.yaml" "!" "-name" "generate.yml")

# Execute find command with constructed options and extensions
find "$path" -maxdepth "$depth" \( "${extensions[@]}" \) "${ignore[@]}" -exec sh -c '
Expand Down
7 changes: 0 additions & 7 deletions examples/rest-api.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
schema
@server(port: 8000, hostname: "0.0.0.0")
@upstream(httpCache: 42)
@link(type: Operation, src: "operations/routes.graphql") {
query: Query
}

type Query {
posts: [Post] @http(url: "http://jsonplaceholder.typicode.com/posts")
users: [User] @http(url: "http://jsonplaceholder.typicode.com/users")
Expand Down
Loading
Loading