GraphQL (any backend)
GraphQL's response shape doesn't match what flux.bootstrap() expects out of the box — a query returns { data, errors } over a single POST endpoint, not { ok, data, assets }. This page covers the thin reshaping layer every GraphQL setup needs, and the one gotcha (errors-under-200) that breaks bootstrap silently if you skip it.
- Any GraphQL server — Apollo Server, Hasura, GraphQL Yoga, or a managed provider
- A thin server-side route (Next.js Route Handler, Express, etc.) to reshape the response — see Step 1
- For plain-REST backends with no GraphQL layer, see bootstrap/rest instead
- Familiarity with api/bootstrap on the client side
Why GraphQL needs its own page
{ ok, data, assets } contract directly. GraphQL cannot — the protocol's own response shape is fixed, and it reports failure differently than Flux expects.Every pattern below is a small server-side route that sits between your GraphQL endpoint and Flux, executing the query and reshaping the result. Flux's client never talks to your GraphQL endpoint directly.
Write one query, aliased to your map keys
map object expects. A single GraphQL query naturally covers what REST needs several endpoints for — a good fit for Flux's one-call bootstrap model.Node — reshaping via graphql-request
errors array is what turns a partial GraphQL failure into a real 5xx.Managed GraphQL (Hasura, etc.) via plain fetch
errors explicitly, since res.ok being true tells you nothing about whether the query actually succeeded.Partial errors — pick fail-closed or fail-open, deliberately
errors. Flux has no concept of a partial bootstrap — decide which behavior you want rather than letting it happen by accident.assets[] stays empty — orthogonal to GraphQL
The Date header — usually fine, one thing to check
clockSkewMs correction depends on this header, and it comes from your reshaping route's response, not the upstream GraphQL server — this is normally correct by default.Extending to a 'user'-scope endpoint
userId.Status codes and how the client reacts
When using GraphQL with Flux, always enforce fail-closed status checking. Since GraphQL naturally returns 200 OK for partial errors, transforming any payload containing an errors array into an HTTP 500 error on the proxy route guarantees that client-side IDB cache fallback and retry semantics function as expected.
For plain-REST backends with no GraphQL layer, see bootstrap/rest. For Node-specific patterns including assets[] chunk warming, see bootstrap/node. For the client-side call this endpoint answers, see api/bootstrap.