Skip to content
Merged
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
26 changes: 26 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Deploy
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
environment: cloudflare
concurrency: deploy-group
permissions:
contents: read
steps:
- uses: actions/checkout@v7
- uses: oven-sh/setup-bun@v2
- uses: cloudflare/wrangler-action@v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
secrets: |
APOLLO_GRAPH_REF
APOLLO_KEY
GITHUB_API_TOKEN
env:
APOLLO_GRAPH_REF: ${{ secrets.APOLLO_GRAPH_REF }}
APOLLO_KEY: ${{ secrets.APOLLO_KEY }}
GITHUB_API_TOKEN: ${{ secrets.GH_API_TOKEN }}
21 changes: 0 additions & 21 deletions .github/workflows/fly-deploy.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/fly-review.yml

This file was deleted.

8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# Dependencies
node_modules/

# Cloudflare
.wrangler/
.dev.vars

# Environment
.env
mise.local.toml
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $ APOLLO_GRAPH_REF=dalestudy@current \
```sh
$ curl --request POST \
--header 'content-type: application/json' \
--url 'https://dalestudy.fly.dev/' \
--url 'https://graphql.daleseo.workers.dev/' \
--data '{"query":"query { __typename }"}'
{"data":{"__typename":"Query"}}%
```
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
FROM ghcr.io/apollographql/router:v2.13.0
COPY router.yaml /dist/config/router.yaml
EXPOSE 8080
197 changes: 197 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

22 changes: 0 additions & 22 deletions fly.toml

This file was deleted.

9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "dalestudy-graphql",
"private": true,
"devDependencies": {
"@cloudflare/containers": "latest",
"@cloudflare/workers-types": "latest",
"wrangler": "latest"
}
}
29 changes: 29 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Container, getContainer } from "@cloudflare/containers";

interface Env {
ROUTER: DurableObjectNamespace<RouterContainer>;
APOLLO_GRAPH_REF: string;
APOLLO_KEY: string;
GITHUB_API_TOKEN: string;
}

export class RouterContainer extends Container<Env> {
defaultPort = 8080;
sleepAfter = "30m";
enableInternet = true; // Apollo Uplink과 GitHub subgraph로의 아웃바운드 통신에 필요

// Worker에 바인딩된 시크릿을 컨테이너 환경 변수로 전달
// (필드 초기화는 super() 이후 실행되므로 this.env 접근 가능)
envVars = {
APOLLO_GRAPH_REF: this.env.APOLLO_GRAPH_REF,
APOLLO_KEY: this.env.APOLLO_KEY,
GITHUB_API_TOKEN: this.env.GITHUB_API_TOKEN,
};
}

export default {
// 이름 생략 시 단일 인스턴스로 라우팅되며, .fetch()가 컨테이너를 자동 기동한다
fetch(request: Request, env: Env) {
return getContainer(env.ROUTER).fetch(request);
},
};
10 changes: 10 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler",
"lib": ["ES2022"],
"types": ["@cloudflare/workers-types"],
"skipLibCheck": true
}
}
18 changes: 18 additions & 0 deletions wrangler.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name = "graphql"
account_id = "86aa227176a624680f7d34e691472576"
main = "src/index.ts"
compatibility_date = "2026-03-01"

[[containers]]
class_name = "RouterContainer"
image = "./Dockerfile"
instance_type = "basic"
max_instances = 1

[[durable_objects.bindings]]
name = "ROUTER"
class_name = "RouterContainer"

[[migrations]]
tag = "v1"
new_sqlite_classes = ["RouterContainer"]
Loading