# Zero-Trust Headless WPGraphQL: Hardening Decoupled Public Endpoints

> A practical framework for query complexity gating, depth limiting, and secret shielding in production decoupled environments.

[Canonical page](https://mifantwan.com/journal/zero-trust-headless-wpgraphql/)

Written by Mifan Twan Ardana · 2026-08-08

## 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.
