grx

Runtime boundaries

What grx owns and what belongs to your application or deployment platform.

grx owns GraphQL behavior. Your application and deployment platform own the system around the GraphQL handler.

Responsibility map

ConcernOwnerTypical grx integration
Schema, parsing, validation, and executiongrxschema.Config, grx.NewServer
HTTP, WebSocket, and SSE GraphQL protocolsgrxBuilt-in transports
Field and operation policySharedAuthorizers, plugins, and application rules
CORS and browser preflightHost applicationMiddleware around the handler
Authentication extractionHost applicationRouter middleware or WebSocket OnConnect
TLS and public routingProxy or hostReverse proxy and router configuration
Database, transactions, and business rulesApplicationServices called by resolvers
Metrics, tracing, and request IDsHost and observability stackMiddleware and plugins
Scaling and connection routingDeployment platformShared pub/sub and load balancer policy

CORS is outside the GraphQL runtime

grx returns an http.Handler. Wrap that handler with the CORS middleware for your HTTP stack. This lets one policy cover GraphQL, health checks, and other routes owned by the host application.

See CORS and browsers for preflight requests, credentials, allowed headers, and router examples.

HTTP CORS does not configure WebSocket origins. Set an explicit origin policy with websocket.Config.CheckOrigin for browser WebSocket connections.

Security boundaries

Parse authentication credentials in host middleware or in the WebSocket OnConnect hook. Use grx operation and field authorizers for decisions that need GraphQL operation or field information.

For cookie-based browser sessions, add CSRF protection at the host boundary. Do not treat a GraphQL field authorizer as a replacement for CSRF checks.

Rate limits, IP allowlists, WAF rules, and TLS policy usually belong at the edge or in host middleware. GraphQL-specific request limits belong in grx.

Operational boundaries

The host application or platform should provide:

  • Request IDs and trace propagation.
  • Logs, metrics, and exporters.
  • Liveness and readiness endpoints.
  • Configuration and secret loading.
  • Graceful shutdown and connection draining.
  • Reverse proxy, TLS, and load balancer settings.

Use grx plugins when the work needs GraphQL lifecycle data. Use host middleware when it needs HTTP headers, cookies, or the full application route.

Data and business boundaries

Resolvers should call application services. Services and repositories own database access, transactions, caching, queues, and background jobs. This keeps business rules independent of GraphQL and makes them reusable from other entry points.

Continue

Edit this page on GitHub

Last updated on

On this page