Skip to content

feat: proxy cloud event queries to dq behind DQ_ENDPOINT flag#78

Open
elffjs wants to merge 1 commit intomainfrom
feat/proxy-to-dq
Open

feat: proxy cloud event queries to dq behind DQ_ENDPOINT flag#78
elffjs wants to merge 1 commit intomainfrom
feat/proxy-to-dq

Conversation

@elffjs
Copy link
Copy Markdown
Member

@elffjs elffjs commented Apr 22, 2026

Summary

  • Adds a DQ_ENDPOINT setting that, when non-empty, forwards all five GraphQL query resolvers to the unified dq service instead of querying ClickHouse/S3 directly.
  • Mirrors the forwarding pattern already shipped in telemetry-api (feat/proxy-to-dq), so both services migrate to dq the same way.
  • Auth is still validated locally (requireSubjectOptsByDID) before proxying; the raw Authorization header is captured by middleware and forwarded to dq so no re-signing is needed.

Query mapping

fetch-api query dq query notes
latestCloudEvent latestCloudEvent full payload (header, data, dataBase64, dataUrl)
cloudEvents cloudEvents full payload
availableCloudEventTypes availableCloudEventTypes passthrough
latestIndex latestCloudEvent (header only) returns indexKey: "" since dq dropped that field
indexes cloudEvents (header only) returns indexKey: ""

The did argument maps directly to dq's subject (same DID string, no conversion). The resolved canonical subject from requireSubjectOptsByDID is used so device-DID → vehicle-DID linking still works under the proxy.

Test plan

  • go build ./... and go test ./... pass
  • With DQ_ENDPOINT unset, existing ClickHouse path is unchanged
  • With DQ_ENDPOINT=http://dq:3000/query, issue each of the five queries against fetch-api and confirm requests reach dq with the forwarded Authorization header
  • Verify latestIndex / indexes return indexKey: "" under the proxy path
  • Verify latestCloudEvent / cloudEvents return inline data / dataBase64 / presigned dataUrl as appropriate

🤖 Generated with Claude Code

When DQ_ENDPOINT is set, all five GraphQL query resolvers forward
to the unified dq service instead of hitting ClickHouse/S3 directly.
Auth is validated locally first; the raw JWT is forwarded to dq.

latestIndex/indexes are mapped to dq's latestCloudEvent/cloudEvents
(header-only selection) and return indexKey: "" since dq no longer
exposes that field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant