-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgraphql-service.ts
More file actions
64 lines (58 loc) · 1.89 KB
/
Copy pathgraphql-service.ts
File metadata and controls
64 lines (58 loc) · 1.89 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
// 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
* @param request - The GraphQL request
* @param context - Optional execution context (e.g. auth user)
* @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;
}