Skip to content

Commit

Permalink
chore: sync latest from wundergraph/cosmo (#8)
Browse files Browse the repository at this point in the history
* feat: expose type data and record subgraphs for enums (wundergraph#1495)

* chore(release): Publish [skip ci]

 - [email protected]
 - [email protected]
 - @wundergraph/[email protected]
 - [email protected]
 - @wundergraph/[email protected]
 - [email protected]

* feat: improve rate limit responses (add code, hide stats) (wundergraph#1497)

* chore(release): Publish [skip ci]

 - [email protected]

* fix: provider should be specified in the config.yaml (wundergraph#1397)

* fix: update the timeouts for clickhouse and platform service (wundergraph#1500)

* chore(release): Publish [skip ci]

 - [email protected]
 - [email protected]
 - [email protected]

* fix: add edfs to the demo environment (wundergraph#1505)

* docs(CONTRIBUTING): fixup minor mistake in CONTRIBUTING.md under Go workspace (wundergraph#1502)

Co-authored-by: Dustin Deus <[email protected]>

* fix: full demo broken in main branch (wundergraph#1508)

* feat(router): optionally add jitter to config polling interval (wundergraph#1506)

Co-authored-by: Dustin Deus <[email protected]>

* chore(release): Publish [skip ci]

 - [email protected]

* fix(router): remove wildcard from router graphql path (wundergraph#1509)

* fix: use gauge for server.uptime metric (wundergraph#1510)

Co-authored-by: Ludwig <[email protected]>

* feat: cache warmer (wundergraph#1501)

Co-authored-by: Ludwig <[email protected]>
Co-authored-by: starptech <[email protected]>

* chore(release): Publish [skip ci]

 - [email protected]
 - @wundergraph/[email protected]
 - [email protected]
 - @wundergraph/[email protected]
 - [email protected]
 - [email protected]
 - [email protected]
 - @wundergraph/[email protected]
 - [email protected]

* fix(cache warmup): consider only po of the last 7 days (wundergraph#1513)

* chore(release): Publish [skip ci]

 - [email protected]

* fix(cache operation): swallow cache errors and other improvements (wundergraph#1515)

* chore(release): Publish [skip ci]

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* feat: add variables remapping support (wundergraph#1516)

Co-authored-by: starptech <[email protected]>

* chore(release): Publish [skip ci]

 - [email protected]

* fix(router): write proper line endings and header for multipart (wundergraph#1517)

* chore(release): Publish [skip ci]

 - [email protected]

* feat(router): optimize playground delivery, add concurrency_limit to config (wundergraph#1519)

* fix(router): enable health checks during startup (wundergraph#1529)

* feat: improve cache warmer (wundergraph#1530)

Co-authored-by: Ludwig <[email protected]>

* chore(release): Publish [skip ci]

 - [email protected]
 - [email protected]
 - [email protected]

* fix: remove semaphore from ResolveGraphQLSubscription (wundergraph#1532)

* chore(release): Publish [skip ci]

 - [email protected]

* feat: add compatibility handshake between router and execution config (wundergraph#1534)

* chore(release): Publish [skip ci]

 - [email protected]
 - @wundergraph/[email protected]
 - @wundergraph/[email protected]
 - [email protected]
 - [email protected]
 - @wundergraph/[email protected]
 - [email protected]

* feat: also add handshake for static execution configs (wundergraph#1535)

* chore(router): bump demo library to pickup subscription fix (wundergraph#1518)

* feat(router): add interface for trace propagation (wundergraph#1526)

* chore(release): Publish [skip ci]

 - [email protected]

* fix: adding/removing directive is not picked up by wgc subgraph check (wundergraph#1494)

* chore(deps): upgrade ristretto to v2 (wundergraph#1538)

* feat: add normalizedQuery to query plan and request info to trace (wundergraph#1536)

Co-authored-by: df-wg <[email protected]>

* fix: add copy button to subgraph routing url (wundergraph#1543)

Co-authored-by: Dustin Deus <[email protected]>

* fix: webhooks shot when schema is unchanged (wundergraph#1542)

* fix: trim the inputs of group mappers (wundergraph#1541)

* fix: subgraphs search functionality (wundergraph#1540)

* chore(release): Publish [skip ci]

 - [email protected]
 - [email protected]
 - [email protected]
 - [email protected]

* fix: increase max concurrent resolvers (wundergraph#1544)

* refactor(router): redesign JWK authentication logic (wundergraph#1498)

* chore(release): Publish [skip ci]

 - [email protected]

* fix: increase the test timeout value to prevent failures on slower machines (wundergraph#1547)

* fix: reduce the breaking change retention duration (wundergraph#1550)

* fix: change the defaults of breaking-change-retention (wundergraph#1551)

* feat(router): enable starting the router without subgraphs (wundergraph#1533)

* fix(router): parse accept header per rfc 9110 (wundergraph#1549)

* chore(release): Publish [skip ci]

 - [email protected]
 - [email protected]
 - [email protected]

* feat(router): enable using redis clusters for rate limiting and apq (wundergraph#1499)

* fix: json schema for traffic shaping subgraphs (wundergraph#1552)

* chore: Update aws-lambda-router customisation after upstream sync

---------

Co-authored-by: Nithin Kumar B <[email protected]>
Co-authored-by: hardworker-bot <[email protected]>
Co-authored-by: Jens Neuse <[email protected]>
Co-authored-by: Alessandro Pagnin <[email protected]>
Co-authored-by: Suvij Surya <[email protected]>
Co-authored-by: endigma <[email protected]>
Co-authored-by: Dustin Deus <[email protected]>
Co-authored-by: Ludwig <[email protected]>
Co-authored-by: Sergiy 🇺🇦 <[email protected]>
Co-authored-by: df-wg <[email protected]>
Co-authored-by: Aenimus <[email protected]>
  • Loading branch information
12 people authored Jan 31, 2025
1 parent 08cb5a8 commit 5ab91a9
Show file tree
Hide file tree
Showing 316 changed files with 52,618 additions and 10,833 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/router-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@ jobs:
with:
cache-dependency-path: |
router-tests/go.sum
- name: Setup Redis Cluster (for Cluster tests)
uses: vishnudxb/[email protected]
with:
master1-port: 7000
master2-port: 7001
master3-port: 7002
slave1-port: 7003
slave2-port: 7004
slave3-port: 7005
sleep-duration: 5
- uses: nick-fields/retry@v3
with:
timeout_minutes: 30
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ This guide assumes you have already installed the following software:
- Node.js [LTS](https://nodejs.org/en/about/releases/). You can also pnpm to [install](https://pnpm.io/cli/env) Node.js.
- [docker desktop](https://docs.docker.com/desktop/) (includes: engine, buildkit & compose) **or**:
- [docker engine](https://docs.docker.com/engine/) with:
- [docker buildkit](https://docs.docker.com/build/buildkit/), with optionally: [docker buildx plugin](https://docs.docker.com/build/install-buildx/)
- [docker compose plugin](https://docs.docker.com/compose/install/#scenario-two-install-the-compose-plugin)
- [docker buildkit](https://docs.docker.com/build/buildkit/), with optionally: [docker buildx plugin](https://docs.docker.com/build/install-buildx/)
- [docker compose plugin](https://docs.docker.com/compose/install/#scenario-two-install-the-compose-plugin)

## Monorepo

Expand All @@ -39,7 +39,7 @@ Ready! You can now start contributing to the WunderGraph Cosmo repository. Feel

## Go workspace

According to best practices, we don't commit the `go.work` or `go.sum` files. Those files are personal to each developer. As a result, we use the `go.mod` file to manage the dependencies and overwrites. You can still create `go.work` file in the root of the repository if you are feeling more comfortable with it or to improve tooling support.
According to best practices, we don't commit the `go.work` or `go.work.sum` files. Those files are personal to each developer. As a result, we use the `go.mod` file to manage the dependencies and overwrites. You can still create `go.work` file in the root of the repository if you are feeling more comfortable with it or to improve tooling support.

### Example

Expand Down Expand Up @@ -183,4 +183,4 @@ Grafana is available at [http://localhost:9300](http://localhost:9300) with the
```
Username: admin
Password: admin
```
```
2 changes: 1 addition & 1 deletion admission-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ FROM --platform=${BUILDPLATFORM} node:lts-slim

WORKDIR /app

ENV NODE_ENV production
ENV NODE_ENV=production

# Fetch built artifacts
COPY --from=builder /app/pruned .
Expand Down
7 changes: 3 additions & 4 deletions aws-lambda-router/config.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
version: '1'

authentication:
providers:
- name: Test Auth Service
jwks:
jwt:
jwks:
- url: https://www.googleapis.com/oauth2/v3/certs
# Example JWKS - Google OIDC
url: https://www.googleapis.com/oauth2/v3/certs
refresh_interval: 5m
headers:
all:
Expand Down
6 changes: 3 additions & 3 deletions aws-lambda-router/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.23.4
require (
github.com/akrylysov/algnhsa v1.1.0
github.com/aws/aws-lambda-go v1.43.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.10.0
github.com/wundergraph/cosmo/router v0.0.0-20241115174502-7156536a93bf
go.uber.org/zap v1.27.0
)
Expand All @@ -26,7 +26,7 @@ require (
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cloudflare/backoff v0.0.0-20161212185259-647f3cdfc87a // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgraph-io/ristretto v0.1.2-0.20240723054643-f5997484152c // indirect
github.com/dgraph-io/ristretto/v2 v2.1.0 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/expr-lang/expr v1.16.9 // indirect
Expand Down Expand Up @@ -97,7 +97,7 @@ require (
github.com/twmb/franz-go v1.16.1 // indirect
github.com/twmb/franz-go/pkg/kmsg v1.7.0 // indirect
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 // indirect
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.138.0.20250106145350-20e4f82cea6b // indirect
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.145 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.23.0 // indirect
Expand Down
17 changes: 12 additions & 5 deletions aws-lambda-router/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRB
github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo=
github.com/akrylysov/algnhsa v1.1.0 h1:G0SoP16tMRyiism7VNc3JFA0wq/cVgEkp/ExMVnc6PQ=
github.com/akrylysov/algnhsa v1.1.0/go.mod h1:+bOweRs/WBu5awl+ifCoSYAuKVPAmoTk8XOMrZ1xwiw=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302 h1:uvdUDbHQHO85qeSydJtItA4T55Pw6BtAejd0APRJOCE=
github.com/alicebob/gopher-json v0.0.0-20230218143504-906a9b012302/go.mod h1:SGnFV6hVsYE877CKEZ6tDNTjaSXYUk6QqoIK6PrAtcc=
github.com/alicebob/miniredis/v2 v2.34.0 h1:mBFWMaJSNL9RwdGRyEDoAAv8OQc5UlEhLDQggTglU/0=
github.com/alicebob/miniredis/v2 v2.34.0/go.mod h1:kWShP4b58T1CW0Y5dViCd5ztzrDqRWqM3nksiyXk5s8=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
github.com/aws/aws-lambda-go v1.43.0 h1:Tdu7SnMB5bD+CbdnSq1Dg4sM68vEuGIDcQFZ+IjUfx0=
Expand Down Expand Up @@ -40,8 +44,8 @@ github.com/coder/websocket v1.8.12/go.mod h1:LNVeNrXQZfe5qhS9ALED3uA+l5pPqvwXg3C
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/ristretto v0.1.2-0.20240723054643-f5997484152c h1:V2+MhiAoTwUNENo9PFoz2NSr0VDJEzIARLuzb30YyqA=
github.com/dgraph-io/ristretto v0.1.2-0.20240723054643-f5997484152c/go.mod h1:swkazRqnUf1N62d0Nutz7KIj2UKqsm/H8tD0nBJAXqM=
github.com/dgraph-io/ristretto/v2 v2.1.0 h1:59LjpOJLNDULHh8MC4UaegN52lC4JnO2dITsie/Pa8I=
github.com/dgraph-io/ristretto/v2 v2.1.0/go.mod h1:uejeqfYXpUomfse0+lO+13ATz4TypQYLJZzBSAemuB4=
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y=
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
Expand Down Expand Up @@ -230,8 +234,9 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
Expand All @@ -256,8 +261,10 @@ github.com/vektah/gqlparser/v2 v2.5.16 h1:1gcmLTvs3JLKXckwCwlUagVn/IlV2bwqle0vJ0
github.com/vektah/gqlparser/v2 v2.5.16/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww=
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083 h1:8/D7f8gKxTBjW+SZK4mhxTTBVpxcqeBgWF1Rfmltbfk=
github.com/wundergraph/astjson v0.0.0-20250106123708-be463c97e083/go.mod h1:eOTL6acwctsN4F3b7YE+eE2t8zcJ/doLm9sZzsxxxrE=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.138.0.20250106145350-20e4f82cea6b h1:DnIV7YVjrPcrJj2awt8M1F++ql6EfC0hB0Or0m4OXx4=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.138.0.20250106145350-20e4f82cea6b/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.145 h1:3JuBmRux6YB/UZgh6COvgLXzQhMIsdHV7A02NsYdAVE=
github.com/wundergraph/graphql-go-tools/v2 v2.0.0-rc.145/go.mod h1:B7eV0Qh8Lop9QzIOQcsvKp3S0ejfC6mgyWoJnI917yQ=
github.com/yuin/gopher-lua v1.1.1 h1:kYKnWBjvbNP4XLT3+bPEwAXJx262OhaHDWDVOPjL46M=
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 h1:aFJWCqJMNjENlcleuuOkGAPH82y0yULBScfXcIEdS24=
Expand Down
123 changes: 82 additions & 41 deletions aws-lambda-router/internal/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,47 +199,9 @@ func NewRouter(opts ...Option) (*core.Router, error) {
routerOpts = append(routerOpts, core.WithAccessLogs(c))
}

var authenticators []authentication.Authenticator
for i, auth := range cfg.Authentication.Providers {
if auth.JWKS != nil {
name := auth.Name
if name == "" {
name = fmt.Sprintf("jwks-#%d", i)
}
providerLogger := logger.With(zap.String("provider_name", name))
tokenDecoder, err := authentication.NewJwksTokenDecoder(ctx, providerLogger, auth.JWKS.URL, auth.JWKS.RefreshInterval)
if err != nil {
providerLogger.Error("Could not create JWKS token decoder", zap.Error(err))
return nil, err
}
opts := authentication.HttpHeaderAuthenticatorOptions{
Name: name,
URL: auth.JWKS.URL,
HeaderNames: auth.JWKS.HeaderNames,
HeaderValuePrefixes: auth.JWKS.HeaderValuePrefixes,
TokenDecoder: tokenDecoder,
}
authenticator, err := authentication.NewHttpHeaderAuthenticator(opts)
if err != nil {
providerLogger.Error("Could not create HttpHeader authenticator", zap.Error(err))
return nil, err
}
authenticators = append(authenticators, authenticator)

if cfg.WebSocket.Authentication.FromInitialPayload.Enabled {
opts := authentication.WebsocketInitialPayloadAuthenticatorOptions{
TokenDecoder: tokenDecoder,
Key: cfg.WebSocket.Authentication.FromInitialPayload.Key,
HeaderValuePrefixes: auth.JWKS.HeaderValuePrefixes,
}
authenticator, err = authentication.NewWebsocketInitialPayloadAuthenticator(opts)
if err != nil {
providerLogger.Error("Could not create WebsocketInitialPayload authenticator", zap.Error(err))
return nil, err
}
authenticators = append(authenticators, authenticator)
}
}
authenticators, err := setupAuthenticators(ctx, logger, cfg)
if err != nil {
return nil, fmt.Errorf("could not setup authenticators: %w", err)
}

if len(authenticators) > 0 {
Expand Down Expand Up @@ -352,3 +314,82 @@ func WithLogger(logger *zap.Logger) Option {
r.Logger = logger
}
}

func setupAuthenticators(ctx context.Context, logger *zap.Logger, cfg *config.Config) ([]authentication.Authenticator, error) {
jwtConf := cfg.Authentication.JWT
if len(jwtConf.JWKS) == 0 {
// No JWT authenticators configured
return nil, nil
}

var authenticators []authentication.Authenticator
configs := make([]authentication.JWKSConfig, 0, len(jwtConf.JWKS))

for _, jwks := range cfg.Authentication.JWT.JWKS {
configs = append(configs, authentication.JWKSConfig{
URL: jwks.URL,
RefreshInterval: jwks.RefreshInterval,
AllowedAlgorithms: jwks.Algorithms,
})
}

tokenDecoder, err := authentication.NewJwksTokenDecoder(ctx, logger, configs)
if err != nil {
return nil, err
}

// create a map for the `httpHeaderAuthenticator`
headerSourceMap := map[string][]string{
jwtConf.HeaderName: {jwtConf.HeaderValuePrefix},
}

// The `websocketInitialPayloadAuthenticator` has one key and uses a flat list of prefixes
prefixSet := make(map[string]struct{})

for _, s := range jwtConf.HeaderSources {
if s.Type != "header" {
continue
}

for _, prefix := range s.ValuePrefixes {
headerSourceMap[s.Name] = append(headerSourceMap[s.Name], prefix)
prefixSet[prefix] = struct{}{}
}

}

opts := authentication.HttpHeaderAuthenticatorOptions{
Name: "jwks",
HeaderSourcePrefixes: headerSourceMap,
TokenDecoder: tokenDecoder,
}

authenticator, err := authentication.NewHttpHeaderAuthenticator(opts)
if err != nil {
logger.Error("Could not create HttpHeader authenticator", zap.Error(err))
return nil, err
}

authenticators = append(authenticators, authenticator)

if cfg.WebSocket.Authentication.FromInitialPayload.Enabled {
headerPrefixes := make([]string, 0, len(prefixSet))
for prefix := range prefixSet {
headerPrefixes = append(headerPrefixes, prefix)
}

opts := authentication.WebsocketInitialPayloadAuthenticatorOptions{
TokenDecoder: tokenDecoder,
Key: cfg.WebSocket.Authentication.FromInitialPayload.Key,
HeaderValuePrefixes: headerPrefixes,
}
authenticator, err = authentication.NewWebsocketInitialPayloadAuthenticator(opts)
if err != nil {
logger.Error("Could not create WebsocketInitialPayload authenticator", zap.Error(err))
return nil, err
}
authenticators = append(authenticators, authenticator)
}

return authenticators, nil
}
2 changes: 1 addition & 1 deletion aws-lambda-router/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aws-lambda-router",
"version": "0.5.0",
"version": "0.6.0",
"private": true,
"description": "Placeholder package to simplify versioning and releasing with lerna.",
"keywords": [
Expand Down
12 changes: 12 additions & 0 deletions cdn-server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ Binaries are attached to the github release otherwise all images can be found [h
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.13.0](https://github.com/wundergraph/cosmo/compare/[email protected]@0.13.0) (2025-01-17)

### Features

* cache warmer ([#1501](https://github.com/wundergraph/cosmo/issues/1501)) ([948edd2](https://github.com/wundergraph/cosmo/commit/948edd23e6d0ee968c91edd1a9e9943c3405ac2d)) (@JivusAyrus)

# [0.12.0](https://github.com/wundergraph/cosmo/compare/[email protected]@0.12.0) (2025-01-08)

### Features

* expose type data and record subgraphs for enums ([#1495](https://github.com/wundergraph/cosmo/issues/1495)) ([9e13f28](https://github.com/wundergraph/cosmo/commit/9e13f28c0a90b0d2f335c9b31f35e728c4a1799c)) (@thisisnithin)

## [0.11.2](https://github.com/wundergraph/cosmo/compare/[email protected]@0.11.2) (2024-12-06)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion cdn-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ FROM --platform=${BUILDPLATFORM} node:lts-slim

WORKDIR /app

ENV NODE_ENV production
ENV NODE_ENV=production

# Fetch built artifacts
COPY --from=builder /app/pruned .
Expand Down
6 changes: 6 additions & 0 deletions cdn-server/cdn/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Binaries are attached to the github release otherwise all images can be found [h
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [0.8.0](https://github.com/wundergraph/cosmo/compare/@wundergraph/[email protected]...@wundergraph/[email protected]) (2025-01-17)

### Features

* cache warmer ([#1501](https://github.com/wundergraph/cosmo/issues/1501)) ([948edd2](https://github.com/wundergraph/cosmo/commit/948edd23e6d0ee968c91edd1a9e9943c3405ac2d)) (@JivusAyrus)

## [0.7.1](https://github.com/wundergraph/cosmo/compare/@wundergraph/[email protected]...@wundergraph/[email protected]) (2024-12-06)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion cdn-server/cdn/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@wundergraph/cosmo-cdn",
"version": "0.7.1",
"version": "0.8.0",
"author": {
"name": "WunderGraph Maintainers",
"email": "[email protected]"
Expand Down
35 changes: 35 additions & 0 deletions cdn-server/cdn/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ const draftRouterConfig = (storage: BlobStorage) => {
};
};

const cacheOperations = (storage: BlobStorage) => {
return async (c: Context) => {
const organizationId = c.get('authenticatedOrganizationId');
const federatedGraphId = c.get('authenticatedFederatedGraphId');

if (organizationId !== c.req.param('organization_id') || federatedGraphId !== c.req.param('federated_graph_id')) {
return c.text('Bad Request', 400);
}

const key = `${organizationId}/${federatedGraphId}/cache_warmup/operations.json`;
let blobObject: BlobObject;

try {
blobObject = await storage.getObject({ context: c, key, cacheControl: 'no-cache' });
} catch (e: any) {
if (e instanceof BlobNotFoundError) {
return c.notFound();
}
throw e;
}

c.header('Content-Type', 'application/json; charset=UTF-8');
c.header('Cache-Control', 'no-cache, no-store, must-revalidate');

return stream(c, async (stream) => {
await stream.pipe(blobObject.stream);
});
};
};

// eslint-disable-next-line @typescript-eslint/ban-types
export const cdn = <E extends Env, S extends Schema = {}, BasePath extends string = '/'>(
hono: Hono<E, S, BasePath>,
Expand All @@ -235,4 +265,9 @@ export const cdn = <E extends Env, S extends Schema = {}, BasePath extends strin
hono
.use(draftRouterConfigs, jwtMiddleware(opts.authAdmissionJwtSecret))
.get(draftRouterConfigs, draftRouterConfig(opts.blobStorage));

const cacheOperationsPath = '/:organization_id/:federated_graph_id/cache_warmup/operations.json';
hono
.use(cacheOperationsPath, jwtMiddleware(opts.authJwtSecret))
.get(cacheOperationsPath, cacheOperations(opts.blobStorage));
};
Loading

0 comments on commit 5ab91a9

Please sign in to comment.