-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgraphql-service.ts
More file actions
74 lines (68 loc) · 2.51 KB
/
Copy pathgraphql-service.ts
File metadata and controls
74 lines (68 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
/**
* IGraphQLService - GraphQL Service Contract
*
* Defines the interface for GraphQL schema and query execution in ObjectStack.
* Concrete implementations (Apollo, Yoga, Mercurius, etc.)
* should implement this interface.
*
* Follows Dependency Inversion Principle - plugins depend on this interface,
* not on concrete GraphQL server implementations.
*
* Aligned with CoreServiceName 'graphql' in core-services.zod.ts.
*/
/**
* A GraphQL execution request
*/
export interface GraphQLRequest {
/** GraphQL query or mutation string */
query: string;
/** Operation name (when document contains multiple operations) */
operationName?: string;
/** Variables for the operation */
variables?: Record<string, unknown>;
}
/**
* A GraphQL execution response
*/
export interface GraphQLResponse {
/** Query result data */
data?: Record<string, unknown> | null;
/** Errors encountered during execution */
errors?: Array<{
message: string;
locations?: Array<{ line: number; column: number }>;
path?: Array<string | number>;
extensions?: Record<string, unknown>;
}>;
}
export interface IGraphQLService {
/**
* Execute a GraphQL query or mutation
*
* ⚠️ Identity admission (ADR-0096 D1, #2992): `context` carries the
* caller's resolved `ExecutionContext`. An implementation that resolves
* objects through the data engine (ObjectQL) MUST forward it on every
* engine call as `options.context` — the security middleware falls OPEN
* on a missing principal, so executing resolvers context-less silently
* grants full authority (no RLS/FLS/CRUD/tenant scoping). The dispatcher's
* `/graphql` entry point threads the caller identity for exactly this
* purpose; dropping it here is a defect, never an authorization.
*
* @param request - The GraphQL request
* @param context - The caller's execution context (auth user / principal)
* @returns GraphQL response with data and/or errors
*/
execute(request: GraphQLRequest, context?: Record<string, unknown>): Promise<GraphQLResponse>;
/**
* Handle an incoming HTTP request for GraphQL
* @param request - Standard Request object
* @returns Standard Response object
*/
handleRequest?(request: Request): Promise<Response>;
/**
* Get the current GraphQL schema as SDL string
* @returns SDL schema string
*/
getSchema?(): string;
}