Class GraphQlSchemaHandler
- Namespace
- Kuestenlogik.Bowire.Protocol.GraphQL.Mock
- Assembly
- Kuestenlogik.Bowire.Protocol.GraphQL.dll
GraphQL schema-only mock handler. Loads an SDL file once at
startup, indexes its type definitions, and answers every
POST /graphql request by parsing the incoming query,
walking the schema for each selected field, and emitting a
sample-valued JSON response that matches the selection set.
public sealed class GraphQlSchemaHandler
- Inheritance
-
GraphQlSchemaHandler
- Inherited Members
Remarks
Unlike OpenAPI / gRPC schema-only (which pre-generate one sample
per operation at startup and feed the normal replay pipeline),
GraphQL responses are selection-set-dependent: { user { name
} } and { user { name, email } } against the same
schema yield different response shapes. That rules out the
synthetic-recording approach and calls for a live handler.
Scope of this first slice:
- Query operations only (Mutations / Subscriptions parsed but emit a generic error).
- Scalars, lists, nullable wrappers, and object types in the selection set.
- Aliases honoured; arguments ignored for sample generation (we don't resolve filter/paging semantics).
- Interfaces / unions skipped — the mock can't guess which
concrete type to emit without runtime resolvers. Fields whose
type is an interface or union return
null.
Methods
LoadAsync(string, ILogger, CancellationToken)
Parse the given SDL file and build a handler ready for request dispatch.
public static Task<GraphQlSchemaHandler> LoadAsync(string path, ILogger logger, CancellationToken ct)
Parameters
pathstringloggerILoggerctCancellationToken
Returns
TryHandleAsync(HttpContext, CancellationToken)
Try to handle the request. Returns true when the
request targeted POST /graphql and a response was
written; false otherwise so the caller can pass through
to the next middleware.
public Task<bool> TryHandleAsync(HttpContext ctx, CancellationToken ct)
Parameters
ctxHttpContextctCancellationToken