Repository navigation
feat(docs): add GitHub GraphQL playground page - #86
Merged
Merged
Conversation
Deploying dang with
|
| Latest commit: |
4c08548
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://02817efa.dang-3kk.pages.dev |
| Branch Preview URL: | https://docs-github-playground.dang-3kk.pages.dev |
vito
force-pushed
the
docs-github-playground
branch
from
June 4, 2026 19:36
76b5e9b to
4022942
Compare
Adds a "GraphQL + Dang playground" docs page that lets readers sign in with GitHub and run snippets that `import GitHub` against the live API, building on the existing client-side WASM playground. GitHub's GraphQL endpoint permits CORS, so introspection and queries run straight from the browser with no proxy; the only server step is the OAuth code-for-token exchange, handled by two small Cloudflare Pages Functions that own the client secret and hand the token back via the URL fragment. The token lives only in the tab's sessionStorage. dangEval now takes an optional token and returns a Promise, since the single-threaded wasm event loop cannot block on the network from a synchronous call. With a token it wires a GitHub ImportConfig into the eval context (introspected once and cached) so `import GitHub` resolves; without one it behaves exactly as before. playground.js gains the auth control and token plumbing for blocks marked data-dang-github, authored via the new \dang-github-playground tag. Operators must register a GitHub OAuth app with callback <site>/github/callback and set GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET (optionally GITHUB_OAUTH_SCOPE), mirroring the feedback webhook setup. Signed-off-by: Alex Suraci <[email protected]>
The "not configured" response was opaque, which made debugging the Cloudflare setup hard. Report exactly which of GITHUB_CLIENT_ID / GITHUB_CLIENT_SECRET is unset in the current environment so a Production-vs-Preview scoping or naming mistake is immediately visible. Signed-off-by: Alex Suraci <[email protected]>
vito
force-pushed
the
docs-github-playground
branch
from
June 4, 2026 21:02
4022942 to
4c08548
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a GraphQL + Dang playground docs page (
/github-playground) that buildson the existing client-side WASM playground. Readers sign in with GitHub, then
run snippets that
import GitHubagainst the live GitHub GraphQL API — types,viewer, etc. all resolve from the real schema.Follows up on docs feedback in Discord asking whether this was possible "in the
current scheme (statically deployed + Cloudflare Functions)." It is — confirmed
GitHub's GraphQL endpoint sends permissive CORS (
access-control-allow-origin: *,allowing
Authorization/Content-Type), so introspection and queries runstraight from the browser with no proxy.
How it fits the static + CF Functions model
ordinary cross-origin fetches from the WASM module to
api.github.com.the OAuth client secret:
GET /github/login→ redirect to GitHub authorize (sets aSameSite=Lax,HttpOnly CSRF-state cookie carrying the return path).
GET /github/callback→ verify state, exchangecodefor a token, bounceback to the page with the token in the URL fragment.
playground.jscaptures#gh_token=…intosessionStorageand strips it.The token lives only in the tab session and is never stored server-side.
Runtime changes
dangEval(source, token)now returns a Promise — the single-threaded wasmevent loop can't block on the network from a synchronous
js.Func. With atoken it wires a GitHub
ImportConfiginto the eval context (schemaintrospected once, then cached for the page lifetime); without one, behavior
is unchanged.
\dang-github-playgroundbooklit tag → a block markeddata-dang-github,which
playground.jsenhances with a sign-in/out control.Operator setup required before sign-in works
Mirrors the feedback webhook setup. Register a GitHub OAuth app with callback
URL
<site>/github/callbackand set encrypted secrets:GITHUB_CLIENT_IDGITHUB_CLIENT_SECRETGITHUB_OAUTH_SCOPE(optional, defaults toread:user)Verification
GOOS=js GOARCH=wasm go build ./cmd/dang-playground✅go build ./...,go vet,gofmtclean ✅./docs/build.shrendersgithub-playground.htmlwith the right markup ✅exercised here — worth eyeballing on the Cloudflare preview once secrets are set.