interface DefaultGraphqlContext

Default context shape that resolvers receive.

Typed against @setu-ts/common (X6-4) so a resolver can reach the service registry and the auth/tenancy principals without hand-written casts.

The per-transport shape is deliberate (X6-6):

  • HTTPrequestContext is present, connection absent.
  • WebSocketconnection is present, requestContext absent (not undefined): the runtime closes the upgrade request once the handshake response is returned, so a synthesized context would be dead by the time a resolver runs. The upgrade request's headers and query live on GraphqlConnectionInfo.headers and .query.

Properties

services: IServiceRegistry

The live service registry (request-scoped over HTTP, plugin-level over WS).

optional
requestContext: IRequestContext

The HTTP request context. Absent over the WebSocket transport.

optional
user: IPrincipal

The authenticated principal, when the auth middleware published one.

optional
tenant: ITenant

The resolved tenant, when tenancy resolved one.

The WebSocket connection info. Present only over the WS transport.

Usage

import { type DefaultGraphqlContext } from "graphql-plugin/src/index.ts";