Zero-Trust Headless WPGraphQL: Hardening Decoupled Public Endpoints
A practical framework for query complexity gating, depth limiting, and secret shielding in production decoupled environments.

## Decoupling Without Expanding the Attack Surface
Exposing a raw `/graphql` endpoint directly to browser clients creates significant risks: arbitrary query depth attacks, introspection leakage, and recursive N+1 denial of service.
The Single-Domain Gateway Strategy
In our architecture, the public browser client never communicates with WordPress directly. The server-rendered frontend functions as an authoritative API gateway:
1. **Persisted Operation Safelists:** Disallow arbitrary query strings in production. 2. **Schema Field Sanitization:** Strip internal author emails, draft revisions, and admin capabilities. 3. **Cache Key Partitioning:** Separate anonymous edge caches from authenticated editor previews.
Related Documentation & Case Studies

Mifan Twan Ardana
· Staff EngineerSpecializing in headless WordPress with WPGraphQL, Shopify Plus storefronts, and calm, high-speed web architecture.