@depup/graphql-tools__delegate 12.0.12-depup.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -0
- package/changes.json +14 -0
- package/dist/index.cjs +3091 -0
- package/dist/index.d.cts +240 -0
- package/dist/index.d.ts +240 -0
- package/dist/index.js +3050 -0
- package/package.json +80 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ExecutionRequest, ExecutionResult, Executor, Maybe, GraphQLResolveInfo as GraphQLResolveInfo$1 } from '@graphql-tools/utils';
|
|
2
|
+
export { createDeferred } from '@graphql-tools/utils';
|
|
3
|
+
import * as graphql from 'graphql';
|
|
4
|
+
import { GraphQLSchema, OperationTypeNode, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, GraphQLFieldResolver, FragmentDefinitionNode, FieldNode, GraphQLNamedType, GraphQLObjectType, GraphQLField, GraphQLInterfaceType, SelectionNode, GraphQLNamedOutputType, TypeInfo, GraphQLType } from 'graphql';
|
|
5
|
+
import DataLoader from 'dataloader';
|
|
6
|
+
import { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
7
|
+
export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
|
|
8
|
+
|
|
9
|
+
declare const UNPATHED_ERRORS_SYMBOL: unique symbol;
|
|
10
|
+
declare const OBJECT_SUBSCHEMA_SYMBOL: unique symbol;
|
|
11
|
+
declare const FIELD_SUBSCHEMA_MAP_SYMBOL: unique symbol;
|
|
12
|
+
|
|
13
|
+
type SchemaTransform<TContext = Record<any, string>> = (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, TContext>) => GraphQLSchema;
|
|
14
|
+
type RequestTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionRequest;
|
|
15
|
+
type ResultTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalResult: ExecutionResult, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionResult;
|
|
16
|
+
interface Transform<T = any, TContext = Record<string, any>> {
|
|
17
|
+
transformSchema?: SchemaTransform<TContext>;
|
|
18
|
+
transformRequest?: RequestTransform<T, TContext>;
|
|
19
|
+
transformResult?: ResultTransform<T, TContext>;
|
|
20
|
+
}
|
|
21
|
+
interface DelegationContext<TContext = Record<string, any>> {
|
|
22
|
+
subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
23
|
+
subschemaConfig?: SubschemaConfig<any, any, any, TContext>;
|
|
24
|
+
targetSchema: GraphQLSchema;
|
|
25
|
+
operation: OperationTypeNode;
|
|
26
|
+
fieldName: string;
|
|
27
|
+
args?: Record<string, any>;
|
|
28
|
+
context?: TContext;
|
|
29
|
+
info?: GraphQLResolveInfo;
|
|
30
|
+
returnType: GraphQLOutputType;
|
|
31
|
+
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
32
|
+
rootValue?: any;
|
|
33
|
+
transforms: Array<Transform<any, TContext>>;
|
|
34
|
+
transformedSchema: GraphQLSchema;
|
|
35
|
+
skipTypeMerging: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs = Record<string, any>> {
|
|
38
|
+
schema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
39
|
+
operationName?: string;
|
|
40
|
+
operation?: OperationTypeNode;
|
|
41
|
+
fieldName?: string;
|
|
42
|
+
returnType?: GraphQLOutputType;
|
|
43
|
+
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
44
|
+
args?: TArgs;
|
|
45
|
+
selectionSet?: SelectionSetNode;
|
|
46
|
+
fieldNodes?: ReadonlyArray<FieldNode>;
|
|
47
|
+
context?: TContext;
|
|
48
|
+
info: GraphQLResolveInfo;
|
|
49
|
+
rootValue?: any;
|
|
50
|
+
transforms?: Array<Transform<any, TContext>>;
|
|
51
|
+
targetSchema?: GraphQLSchema;
|
|
52
|
+
validateRequest?: boolean;
|
|
53
|
+
skipTypeMerging?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface IDelegateRequestOptions<TContext = Record<string, any>, TArgs = Record<string, any>> extends IDelegateToSchemaOptions<TContext, TArgs> {
|
|
56
|
+
request: ExecutionRequest;
|
|
57
|
+
targetSchema: GraphQLSchema;
|
|
58
|
+
}
|
|
59
|
+
interface ICreateRequest {
|
|
60
|
+
subgraphName: string | undefined;
|
|
61
|
+
fragments?: FragmentDefinitionNode[];
|
|
62
|
+
targetOperation: OperationTypeNode;
|
|
63
|
+
targetOperationName?: string;
|
|
64
|
+
targetFieldName: string;
|
|
65
|
+
targetSchema: GraphQLSchema;
|
|
66
|
+
selectionSet?: SelectionSetNode;
|
|
67
|
+
fieldNodes?: ReadonlyArray<FieldNode>;
|
|
68
|
+
rootValue?: any;
|
|
69
|
+
args?: Record<string, any>;
|
|
70
|
+
context?: any;
|
|
71
|
+
info?: GraphQLResolveInfo;
|
|
72
|
+
}
|
|
73
|
+
type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[], context?: any, info?: GraphQLResolveInfo) => Array<Map<Subschema, SelectionSetNode>>;
|
|
74
|
+
interface MergedTypeInfo<TContext = Record<string, any>> {
|
|
75
|
+
typeName: string;
|
|
76
|
+
selectionSet?: SelectionSetNode;
|
|
77
|
+
targetSubschemas: Map<Subschema<any, any, any, TContext>, Array<Subschema<any, any, any, TContext>>>;
|
|
78
|
+
uniqueFields: Record<string, Subschema<any, any, any, TContext>>;
|
|
79
|
+
nonUniqueFields: Record<string, Array<Subschema<any, any, any, TContext>>>;
|
|
80
|
+
typeMaps: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Record<string, GraphQLNamedType>>;
|
|
81
|
+
selectionSets: Map<Subschema<any, any, any, TContext>, SelectionSetNode>;
|
|
82
|
+
fieldSelectionSets: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
|
|
83
|
+
resolvers: Map<Subschema<any, any, any, TContext>, MergedTypeResolver<TContext>>;
|
|
84
|
+
providedSelectionsByField: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
|
|
85
|
+
delegationPlanBuilder: DelegationPlanBuilder;
|
|
86
|
+
nonMemoizedDelegationPlanBuilder: DelegationPlanBuilder;
|
|
87
|
+
}
|
|
88
|
+
interface ICreateProxyingResolverOptions<TContext = Record<string, any>> {
|
|
89
|
+
subschemaConfig: SubschemaConfig<any, any, any, TContext>;
|
|
90
|
+
operation?: OperationTypeNode;
|
|
91
|
+
fieldName?: string;
|
|
92
|
+
}
|
|
93
|
+
type CreateProxyingResolverFn<TContext = Record<string, any>> = (options: ICreateProxyingResolverOptions<TContext>) => GraphQLFieldResolver<any, TContext>;
|
|
94
|
+
interface BatchingOptions<K = any, V = any, C = K> {
|
|
95
|
+
extensionsReducer?: (mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>;
|
|
96
|
+
dataLoaderOptions?: DataLoader.Options<K, V, C>;
|
|
97
|
+
}
|
|
98
|
+
interface SubschemaConfig<K = any, V = any, C = K, TContext = Record<string, any>> {
|
|
99
|
+
name?: string;
|
|
100
|
+
schema: GraphQLSchema;
|
|
101
|
+
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
102
|
+
rootValue?: any;
|
|
103
|
+
transforms?: Array<Transform<any, TContext>>;
|
|
104
|
+
merge?: Record<string, MergedTypeConfig<any, any, TContext>>;
|
|
105
|
+
executor?: Executor<TContext>;
|
|
106
|
+
batch?: boolean;
|
|
107
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
108
|
+
}
|
|
109
|
+
interface MergedTypeConfig<K = any, V = any, TContext = Record<string, any>> extends MergedTypeEntryPoint<K, V, TContext> {
|
|
110
|
+
entryPoints?: Array<MergedTypeEntryPoint>;
|
|
111
|
+
fields?: Record<string, MergedFieldConfig>;
|
|
112
|
+
canonical?: boolean;
|
|
113
|
+
}
|
|
114
|
+
interface MergedTypeEntryPoint<K = any, V = any, TContext = Record<string, any>> extends MergedTypeResolverOptions<K, V> {
|
|
115
|
+
selectionSet?: string;
|
|
116
|
+
key?: (originalResult: any) => K | PromiseLike<K>;
|
|
117
|
+
resolve?: MergedTypeResolver<TContext>;
|
|
118
|
+
}
|
|
119
|
+
interface MergedTypeResolverOptions<K = any, V = any> {
|
|
120
|
+
fieldName?: string;
|
|
121
|
+
args?: (originalResult: any) => Record<string, any>;
|
|
122
|
+
argsFromKeys?: (keys: ReadonlyArray<K>) => Record<string, any>;
|
|
123
|
+
valuesFromResults?: (results: any, keys: ReadonlyArray<K>) => Array<V>;
|
|
124
|
+
dataLoaderOptions?: DataLoader.Options<K, V>;
|
|
125
|
+
}
|
|
126
|
+
type OverrideHandler = (context: any, info: GraphQLResolveInfo) => boolean;
|
|
127
|
+
interface MergedFieldConfig {
|
|
128
|
+
selectionSet?: string;
|
|
129
|
+
computed?: boolean;
|
|
130
|
+
canonical?: boolean;
|
|
131
|
+
provides?: SelectionSetNode;
|
|
132
|
+
override?: OverrideHandler;
|
|
133
|
+
}
|
|
134
|
+
type MergedTypeResolver<TContext = Record<string, any>> = (originalResult: any, context: TContext, info: GraphQLResolveInfo, subschema: Subschema<any, any, any, TContext>, selectionSet: SelectionSetNode, key: any | undefined, type: GraphQLOutputType) => any;
|
|
135
|
+
interface StitchingInfo<TContext = Record<string, any>> {
|
|
136
|
+
subschemaMap: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Subschema<any, any, any, TContext>>;
|
|
137
|
+
fieldNodesByType: Record<string, Array<FieldNode>>;
|
|
138
|
+
fieldNodesByField: Record<string, Record<string, Array<FieldNode>>>;
|
|
139
|
+
dynamicSelectionSetsByField: Record<string, Record<string, Array<(node: FieldNode) => SelectionSetNode>>>;
|
|
140
|
+
mergedTypes: Record<string, MergedTypeInfo<TContext>>;
|
|
141
|
+
}
|
|
142
|
+
interface ExternalObject<TContext = Record<string, any>> {
|
|
143
|
+
__typename: string;
|
|
144
|
+
key: any;
|
|
145
|
+
[OBJECT_SUBSCHEMA_SYMBOL]: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
146
|
+
[FIELD_SUBSCHEMA_MAP_SYMBOL]: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, TContext>>;
|
|
147
|
+
[UNPATHED_ERRORS_SYMBOL]: Array<GraphQLError>;
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare function isSubschema(value: any): value is Subschema;
|
|
152
|
+
interface ISubschema<K = any, V = any, C = K, TContext = Record<string, any>> extends SubschemaConfig<K, V, C, TContext> {
|
|
153
|
+
transformedSchema: GraphQLSchema;
|
|
154
|
+
}
|
|
155
|
+
declare class Subschema<K = any, V = any, C = K, TContext = Record<string, any>> implements ISubschema<K, V, C, TContext> {
|
|
156
|
+
name?: string;
|
|
157
|
+
schema: GraphQLSchema;
|
|
158
|
+
executor?: Executor<TContext>;
|
|
159
|
+
batch?: boolean;
|
|
160
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
161
|
+
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
162
|
+
transforms: Array<Transform<any, TContext>>;
|
|
163
|
+
private _transformedSchema;
|
|
164
|
+
merge?: Record<string, MergedTypeConfig<any, any, TContext>>;
|
|
165
|
+
constructor(config: SubschemaConfig<K, V, C, TContext>);
|
|
166
|
+
get transformedSchema(): GraphQLSchema;
|
|
167
|
+
set transformedSchema(value: GraphQLSchema);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class Transformer<TContext extends Record<string, any> = Record<string, any>> {
|
|
171
|
+
private transformations;
|
|
172
|
+
private delegationContext;
|
|
173
|
+
private hasOverlappingAliases;
|
|
174
|
+
constructor(context: DelegationContext<TContext>);
|
|
175
|
+
private addTransform;
|
|
176
|
+
transformRequest(originalRequest: ExecutionRequest): ExecutionRequest;
|
|
177
|
+
transformResult(originalResult: ExecutionResult): any;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare const applySchemaTransforms: (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, any>) => GraphQLSchema;
|
|
181
|
+
|
|
182
|
+
declare function getDelegatingOperation(parentType: GraphQLObjectType, schema: GraphQLSchema): OperationTypeNode;
|
|
183
|
+
declare function createRequest({ subgraphName, fragments, rootValue, targetOperationName, targetOperation, targetSchema, targetFieldName, selectionSet, fieldNodes, context, info, args, }: ICreateRequest): ExecutionRequest;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Resolver that knows how to:
|
|
187
|
+
* a) handle aliases for proxied schemas
|
|
188
|
+
* b) handle errors from proxied schemas
|
|
189
|
+
* c) handle external to internal enum conversion
|
|
190
|
+
*/
|
|
191
|
+
declare function defaultMergedResolver(parent: ExternalObject, args: Record<string, any>, context: Record<string, any>, info: GraphQLResolveInfo): any;
|
|
192
|
+
|
|
193
|
+
declare function delegateToSchema<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateToSchemaOptions<TContext, TArgs>): any;
|
|
194
|
+
declare function delegateRequest<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateRequestOptions<TContext, TArgs>): any;
|
|
195
|
+
|
|
196
|
+
declare function isExternalObject(data: any): data is ExternalObject;
|
|
197
|
+
declare function annotateExternalObject<TContext>(object: any, errors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext> | undefined, subschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>): ExternalObject;
|
|
198
|
+
declare function getSubschema(object: ExternalObject, responseKey: string): GraphQLSchema | SubschemaConfig;
|
|
199
|
+
declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
|
|
200
|
+
declare const EMPTY_ARRAY: any[];
|
|
201
|
+
declare const EMPTY_OBJECT: any;
|
|
202
|
+
declare const getActualFieldNodes: (fieldNode: FieldNode) => FieldNode[];
|
|
203
|
+
declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo): MaybePromise<any>;
|
|
204
|
+
declare function handleResolverResult(resolverResult: any, subschema: Subschema, selectionSet: SelectionSetNode, object: ExternalObject, combinedFieldSubschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>, info: GraphQLResolveInfo, path: Array<string | number>, combinedErrors: Array<GraphQLError>): void;
|
|
205
|
+
|
|
206
|
+
declare function resolveExternalValue<TContext extends Record<string, any>>(result: any, unpathedErrors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>, context?: Record<string, any>, info?: GraphQLResolveInfo, returnType?: GraphQLOutputType, skipTypeMerging?: boolean): any;
|
|
207
|
+
|
|
208
|
+
declare function isSubschemaConfig(value: any): value is SubschemaConfig<any, any, any, any>;
|
|
209
|
+
declare function cloneSubschemaConfig(subschemaConfig: SubschemaConfig): SubschemaConfig;
|
|
210
|
+
|
|
211
|
+
declare function extractUnavailableFieldsFromSelectionSet(schema: GraphQLSchema, fieldType: GraphQLNamedOutputType, fieldSelectionSet: SelectionSetNode, shouldAdd: (fieldType: GraphQLObjectType | GraphQLInterfaceType, selection: FieldNode) => boolean, fragments?: Record<string, FragmentDefinitionNode>): SelectionNode[];
|
|
212
|
+
declare function extractUnavailableFields(schema: GraphQLSchema, field: GraphQLField<any, any>, fieldNode: FieldNode, shouldAdd: (fieldType: GraphQLObjectType | GraphQLInterfaceType, selection: FieldNode) => boolean, fragments?: Record<string, FragmentDefinitionNode>): SelectionNode[];
|
|
213
|
+
declare function subtractSelectionSets(selectionSetA: SelectionSetNode, selectionSetB: SelectionSetNode): SelectionSetNode;
|
|
214
|
+
|
|
215
|
+
type Deferred<T = unknown> = {
|
|
216
|
+
promise: Promise<T>;
|
|
217
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
218
|
+
reject: (reason?: any) => void;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
interface DelegationPlanLeftOver {
|
|
222
|
+
unproxiableFieldNodes: Array<FieldNode>;
|
|
223
|
+
nonProxiableSubschemas: Array<Subschema>;
|
|
224
|
+
missingFieldsParentMap: Map<ExternalObject, Array<FieldNode>>;
|
|
225
|
+
missingFieldsParentDeferredMap: Map<ExternalObject, Map<string, Deferred>>;
|
|
226
|
+
}
|
|
227
|
+
declare const leftOverByDelegationPlan: WeakMap<Map<Subschema<any, any, any, Record<string, any>>, graphql.SelectionSetNode>[], DelegationPlanLeftOver>;
|
|
228
|
+
declare const PLAN_LEFT_OVER: symbol;
|
|
229
|
+
declare function getPlanLeftOverFromParent(parent: any): DelegationPlanLeftOver | undefined;
|
|
230
|
+
|
|
231
|
+
declare const getTypeInfo: (schema: GraphQLSchema) => TypeInfo;
|
|
232
|
+
declare const getTypeInfoWithType: (schema: GraphQLSchema, type: Maybe<GraphQLType>) => TypeInfo;
|
|
233
|
+
|
|
234
|
+
declare const prototypePollutingKeys: readonly ["__proto__", "constructor", "prototype"];
|
|
235
|
+
type PrototypePollutingKey = (typeof prototypePollutingKeys)[number];
|
|
236
|
+
declare function isPrototypePollutingKey(key: string): key is PrototypePollutingKey;
|
|
237
|
+
|
|
238
|
+
declare const handleOverrideByDelegation: (info: GraphQLResolveInfo$1, context: any, overrideHandler: OverrideHandler) => boolean;
|
|
239
|
+
|
|
240
|
+
export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_ARRAY, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { ExecutionRequest, ExecutionResult, Executor, Maybe, GraphQLResolveInfo as GraphQLResolveInfo$1 } from '@graphql-tools/utils';
|
|
2
|
+
export { createDeferred } from '@graphql-tools/utils';
|
|
3
|
+
import * as graphql from 'graphql';
|
|
4
|
+
import { GraphQLSchema, OperationTypeNode, GraphQLResolveInfo, GraphQLOutputType, GraphQLError, SelectionSetNode, GraphQLFieldResolver, FragmentDefinitionNode, FieldNode, GraphQLNamedType, GraphQLObjectType, GraphQLField, GraphQLInterfaceType, SelectionNode, GraphQLNamedOutputType, TypeInfo, GraphQLType } from 'graphql';
|
|
5
|
+
import DataLoader from 'dataloader';
|
|
6
|
+
import { MaybePromise } from '@whatwg-node/promise-helpers';
|
|
7
|
+
export { executorFromSchema as createDefaultExecutor } from '@graphql-tools/executor';
|
|
8
|
+
|
|
9
|
+
declare const UNPATHED_ERRORS_SYMBOL: unique symbol;
|
|
10
|
+
declare const OBJECT_SUBSCHEMA_SYMBOL: unique symbol;
|
|
11
|
+
declare const FIELD_SUBSCHEMA_MAP_SYMBOL: unique symbol;
|
|
12
|
+
|
|
13
|
+
type SchemaTransform<TContext = Record<any, string>> = (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, TContext>) => GraphQLSchema;
|
|
14
|
+
type RequestTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionRequest;
|
|
15
|
+
type ResultTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalResult: ExecutionResult, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionResult;
|
|
16
|
+
interface Transform<T = any, TContext = Record<string, any>> {
|
|
17
|
+
transformSchema?: SchemaTransform<TContext>;
|
|
18
|
+
transformRequest?: RequestTransform<T, TContext>;
|
|
19
|
+
transformResult?: ResultTransform<T, TContext>;
|
|
20
|
+
}
|
|
21
|
+
interface DelegationContext<TContext = Record<string, any>> {
|
|
22
|
+
subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
23
|
+
subschemaConfig?: SubschemaConfig<any, any, any, TContext>;
|
|
24
|
+
targetSchema: GraphQLSchema;
|
|
25
|
+
operation: OperationTypeNode;
|
|
26
|
+
fieldName: string;
|
|
27
|
+
args?: Record<string, any>;
|
|
28
|
+
context?: TContext;
|
|
29
|
+
info?: GraphQLResolveInfo;
|
|
30
|
+
returnType: GraphQLOutputType;
|
|
31
|
+
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
32
|
+
rootValue?: any;
|
|
33
|
+
transforms: Array<Transform<any, TContext>>;
|
|
34
|
+
transformedSchema: GraphQLSchema;
|
|
35
|
+
skipTypeMerging: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs = Record<string, any>> {
|
|
38
|
+
schema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
39
|
+
operationName?: string;
|
|
40
|
+
operation?: OperationTypeNode;
|
|
41
|
+
fieldName?: string;
|
|
42
|
+
returnType?: GraphQLOutputType;
|
|
43
|
+
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
44
|
+
args?: TArgs;
|
|
45
|
+
selectionSet?: SelectionSetNode;
|
|
46
|
+
fieldNodes?: ReadonlyArray<FieldNode>;
|
|
47
|
+
context?: TContext;
|
|
48
|
+
info: GraphQLResolveInfo;
|
|
49
|
+
rootValue?: any;
|
|
50
|
+
transforms?: Array<Transform<any, TContext>>;
|
|
51
|
+
targetSchema?: GraphQLSchema;
|
|
52
|
+
validateRequest?: boolean;
|
|
53
|
+
skipTypeMerging?: boolean;
|
|
54
|
+
}
|
|
55
|
+
interface IDelegateRequestOptions<TContext = Record<string, any>, TArgs = Record<string, any>> extends IDelegateToSchemaOptions<TContext, TArgs> {
|
|
56
|
+
request: ExecutionRequest;
|
|
57
|
+
targetSchema: GraphQLSchema;
|
|
58
|
+
}
|
|
59
|
+
interface ICreateRequest {
|
|
60
|
+
subgraphName: string | undefined;
|
|
61
|
+
fragments?: FragmentDefinitionNode[];
|
|
62
|
+
targetOperation: OperationTypeNode;
|
|
63
|
+
targetOperationName?: string;
|
|
64
|
+
targetFieldName: string;
|
|
65
|
+
targetSchema: GraphQLSchema;
|
|
66
|
+
selectionSet?: SelectionSetNode;
|
|
67
|
+
fieldNodes?: ReadonlyArray<FieldNode>;
|
|
68
|
+
rootValue?: any;
|
|
69
|
+
args?: Record<string, any>;
|
|
70
|
+
context?: any;
|
|
71
|
+
info?: GraphQLResolveInfo;
|
|
72
|
+
}
|
|
73
|
+
type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[], context?: any, info?: GraphQLResolveInfo) => Array<Map<Subschema, SelectionSetNode>>;
|
|
74
|
+
interface MergedTypeInfo<TContext = Record<string, any>> {
|
|
75
|
+
typeName: string;
|
|
76
|
+
selectionSet?: SelectionSetNode;
|
|
77
|
+
targetSubschemas: Map<Subschema<any, any, any, TContext>, Array<Subschema<any, any, any, TContext>>>;
|
|
78
|
+
uniqueFields: Record<string, Subschema<any, any, any, TContext>>;
|
|
79
|
+
nonUniqueFields: Record<string, Array<Subschema<any, any, any, TContext>>>;
|
|
80
|
+
typeMaps: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Record<string, GraphQLNamedType>>;
|
|
81
|
+
selectionSets: Map<Subschema<any, any, any, TContext>, SelectionSetNode>;
|
|
82
|
+
fieldSelectionSets: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
|
|
83
|
+
resolvers: Map<Subschema<any, any, any, TContext>, MergedTypeResolver<TContext>>;
|
|
84
|
+
providedSelectionsByField: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
|
|
85
|
+
delegationPlanBuilder: DelegationPlanBuilder;
|
|
86
|
+
nonMemoizedDelegationPlanBuilder: DelegationPlanBuilder;
|
|
87
|
+
}
|
|
88
|
+
interface ICreateProxyingResolverOptions<TContext = Record<string, any>> {
|
|
89
|
+
subschemaConfig: SubschemaConfig<any, any, any, TContext>;
|
|
90
|
+
operation?: OperationTypeNode;
|
|
91
|
+
fieldName?: string;
|
|
92
|
+
}
|
|
93
|
+
type CreateProxyingResolverFn<TContext = Record<string, any>> = (options: ICreateProxyingResolverOptions<TContext>) => GraphQLFieldResolver<any, TContext>;
|
|
94
|
+
interface BatchingOptions<K = any, V = any, C = K> {
|
|
95
|
+
extensionsReducer?: (mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>;
|
|
96
|
+
dataLoaderOptions?: DataLoader.Options<K, V, C>;
|
|
97
|
+
}
|
|
98
|
+
interface SubschemaConfig<K = any, V = any, C = K, TContext = Record<string, any>> {
|
|
99
|
+
name?: string;
|
|
100
|
+
schema: GraphQLSchema;
|
|
101
|
+
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
102
|
+
rootValue?: any;
|
|
103
|
+
transforms?: Array<Transform<any, TContext>>;
|
|
104
|
+
merge?: Record<string, MergedTypeConfig<any, any, TContext>>;
|
|
105
|
+
executor?: Executor<TContext>;
|
|
106
|
+
batch?: boolean;
|
|
107
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
108
|
+
}
|
|
109
|
+
interface MergedTypeConfig<K = any, V = any, TContext = Record<string, any>> extends MergedTypeEntryPoint<K, V, TContext> {
|
|
110
|
+
entryPoints?: Array<MergedTypeEntryPoint>;
|
|
111
|
+
fields?: Record<string, MergedFieldConfig>;
|
|
112
|
+
canonical?: boolean;
|
|
113
|
+
}
|
|
114
|
+
interface MergedTypeEntryPoint<K = any, V = any, TContext = Record<string, any>> extends MergedTypeResolverOptions<K, V> {
|
|
115
|
+
selectionSet?: string;
|
|
116
|
+
key?: (originalResult: any) => K | PromiseLike<K>;
|
|
117
|
+
resolve?: MergedTypeResolver<TContext>;
|
|
118
|
+
}
|
|
119
|
+
interface MergedTypeResolverOptions<K = any, V = any> {
|
|
120
|
+
fieldName?: string;
|
|
121
|
+
args?: (originalResult: any) => Record<string, any>;
|
|
122
|
+
argsFromKeys?: (keys: ReadonlyArray<K>) => Record<string, any>;
|
|
123
|
+
valuesFromResults?: (results: any, keys: ReadonlyArray<K>) => Array<V>;
|
|
124
|
+
dataLoaderOptions?: DataLoader.Options<K, V>;
|
|
125
|
+
}
|
|
126
|
+
type OverrideHandler = (context: any, info: GraphQLResolveInfo) => boolean;
|
|
127
|
+
interface MergedFieldConfig {
|
|
128
|
+
selectionSet?: string;
|
|
129
|
+
computed?: boolean;
|
|
130
|
+
canonical?: boolean;
|
|
131
|
+
provides?: SelectionSetNode;
|
|
132
|
+
override?: OverrideHandler;
|
|
133
|
+
}
|
|
134
|
+
type MergedTypeResolver<TContext = Record<string, any>> = (originalResult: any, context: TContext, info: GraphQLResolveInfo, subschema: Subschema<any, any, any, TContext>, selectionSet: SelectionSetNode, key: any | undefined, type: GraphQLOutputType) => any;
|
|
135
|
+
interface StitchingInfo<TContext = Record<string, any>> {
|
|
136
|
+
subschemaMap: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Subschema<any, any, any, TContext>>;
|
|
137
|
+
fieldNodesByType: Record<string, Array<FieldNode>>;
|
|
138
|
+
fieldNodesByField: Record<string, Record<string, Array<FieldNode>>>;
|
|
139
|
+
dynamicSelectionSetsByField: Record<string, Record<string, Array<(node: FieldNode) => SelectionSetNode>>>;
|
|
140
|
+
mergedTypes: Record<string, MergedTypeInfo<TContext>>;
|
|
141
|
+
}
|
|
142
|
+
interface ExternalObject<TContext = Record<string, any>> {
|
|
143
|
+
__typename: string;
|
|
144
|
+
key: any;
|
|
145
|
+
[OBJECT_SUBSCHEMA_SYMBOL]: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
146
|
+
[FIELD_SUBSCHEMA_MAP_SYMBOL]: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, TContext>>;
|
|
147
|
+
[UNPATHED_ERRORS_SYMBOL]: Array<GraphQLError>;
|
|
148
|
+
[key: string]: unknown;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
declare function isSubschema(value: any): value is Subschema;
|
|
152
|
+
interface ISubschema<K = any, V = any, C = K, TContext = Record<string, any>> extends SubschemaConfig<K, V, C, TContext> {
|
|
153
|
+
transformedSchema: GraphQLSchema;
|
|
154
|
+
}
|
|
155
|
+
declare class Subschema<K = any, V = any, C = K, TContext = Record<string, any>> implements ISubschema<K, V, C, TContext> {
|
|
156
|
+
name?: string;
|
|
157
|
+
schema: GraphQLSchema;
|
|
158
|
+
executor?: Executor<TContext>;
|
|
159
|
+
batch?: boolean;
|
|
160
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
161
|
+
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
162
|
+
transforms: Array<Transform<any, TContext>>;
|
|
163
|
+
private _transformedSchema;
|
|
164
|
+
merge?: Record<string, MergedTypeConfig<any, any, TContext>>;
|
|
165
|
+
constructor(config: SubschemaConfig<K, V, C, TContext>);
|
|
166
|
+
get transformedSchema(): GraphQLSchema;
|
|
167
|
+
set transformedSchema(value: GraphQLSchema);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
declare class Transformer<TContext extends Record<string, any> = Record<string, any>> {
|
|
171
|
+
private transformations;
|
|
172
|
+
private delegationContext;
|
|
173
|
+
private hasOverlappingAliases;
|
|
174
|
+
constructor(context: DelegationContext<TContext>);
|
|
175
|
+
private addTransform;
|
|
176
|
+
transformRequest(originalRequest: ExecutionRequest): ExecutionRequest;
|
|
177
|
+
transformResult(originalResult: ExecutionResult): any;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
declare const applySchemaTransforms: (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, any>) => GraphQLSchema;
|
|
181
|
+
|
|
182
|
+
declare function getDelegatingOperation(parentType: GraphQLObjectType, schema: GraphQLSchema): OperationTypeNode;
|
|
183
|
+
declare function createRequest({ subgraphName, fragments, rootValue, targetOperationName, targetOperation, targetSchema, targetFieldName, selectionSet, fieldNodes, context, info, args, }: ICreateRequest): ExecutionRequest;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Resolver that knows how to:
|
|
187
|
+
* a) handle aliases for proxied schemas
|
|
188
|
+
* b) handle errors from proxied schemas
|
|
189
|
+
* c) handle external to internal enum conversion
|
|
190
|
+
*/
|
|
191
|
+
declare function defaultMergedResolver(parent: ExternalObject, args: Record<string, any>, context: Record<string, any>, info: GraphQLResolveInfo): any;
|
|
192
|
+
|
|
193
|
+
declare function delegateToSchema<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateToSchemaOptions<TContext, TArgs>): any;
|
|
194
|
+
declare function delegateRequest<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateRequestOptions<TContext, TArgs>): any;
|
|
195
|
+
|
|
196
|
+
declare function isExternalObject(data: any): data is ExternalObject;
|
|
197
|
+
declare function annotateExternalObject<TContext>(object: any, errors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext> | undefined, subschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>): ExternalObject;
|
|
198
|
+
declare function getSubschema(object: ExternalObject, responseKey: string): GraphQLSchema | SubschemaConfig;
|
|
199
|
+
declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
|
|
200
|
+
declare const EMPTY_ARRAY: any[];
|
|
201
|
+
declare const EMPTY_OBJECT: any;
|
|
202
|
+
declare const getActualFieldNodes: (fieldNode: FieldNode) => FieldNode[];
|
|
203
|
+
declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo): MaybePromise<any>;
|
|
204
|
+
declare function handleResolverResult(resolverResult: any, subschema: Subschema, selectionSet: SelectionSetNode, object: ExternalObject, combinedFieldSubschemaMap: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, Record<string, any>>>, info: GraphQLResolveInfo, path: Array<string | number>, combinedErrors: Array<GraphQLError>): void;
|
|
205
|
+
|
|
206
|
+
declare function resolveExternalValue<TContext extends Record<string, any>>(result: any, unpathedErrors: Array<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>, context?: Record<string, any>, info?: GraphQLResolveInfo, returnType?: GraphQLOutputType, skipTypeMerging?: boolean): any;
|
|
207
|
+
|
|
208
|
+
declare function isSubschemaConfig(value: any): value is SubschemaConfig<any, any, any, any>;
|
|
209
|
+
declare function cloneSubschemaConfig(subschemaConfig: SubschemaConfig): SubschemaConfig;
|
|
210
|
+
|
|
211
|
+
declare function extractUnavailableFieldsFromSelectionSet(schema: GraphQLSchema, fieldType: GraphQLNamedOutputType, fieldSelectionSet: SelectionSetNode, shouldAdd: (fieldType: GraphQLObjectType | GraphQLInterfaceType, selection: FieldNode) => boolean, fragments?: Record<string, FragmentDefinitionNode>): SelectionNode[];
|
|
212
|
+
declare function extractUnavailableFields(schema: GraphQLSchema, field: GraphQLField<any, any>, fieldNode: FieldNode, shouldAdd: (fieldType: GraphQLObjectType | GraphQLInterfaceType, selection: FieldNode) => boolean, fragments?: Record<string, FragmentDefinitionNode>): SelectionNode[];
|
|
213
|
+
declare function subtractSelectionSets(selectionSetA: SelectionSetNode, selectionSetB: SelectionSetNode): SelectionSetNode;
|
|
214
|
+
|
|
215
|
+
type Deferred<T = unknown> = {
|
|
216
|
+
promise: Promise<T>;
|
|
217
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
218
|
+
reject: (reason?: any) => void;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
interface DelegationPlanLeftOver {
|
|
222
|
+
unproxiableFieldNodes: Array<FieldNode>;
|
|
223
|
+
nonProxiableSubschemas: Array<Subschema>;
|
|
224
|
+
missingFieldsParentMap: Map<ExternalObject, Array<FieldNode>>;
|
|
225
|
+
missingFieldsParentDeferredMap: Map<ExternalObject, Map<string, Deferred>>;
|
|
226
|
+
}
|
|
227
|
+
declare const leftOverByDelegationPlan: WeakMap<Map<Subschema<any, any, any, Record<string, any>>, graphql.SelectionSetNode>[], DelegationPlanLeftOver>;
|
|
228
|
+
declare const PLAN_LEFT_OVER: symbol;
|
|
229
|
+
declare function getPlanLeftOverFromParent(parent: any): DelegationPlanLeftOver | undefined;
|
|
230
|
+
|
|
231
|
+
declare const getTypeInfo: (schema: GraphQLSchema) => TypeInfo;
|
|
232
|
+
declare const getTypeInfoWithType: (schema: GraphQLSchema, type: Maybe<GraphQLType>) => TypeInfo;
|
|
233
|
+
|
|
234
|
+
declare const prototypePollutingKeys: readonly ["__proto__", "constructor", "prototype"];
|
|
235
|
+
type PrototypePollutingKey = (typeof prototypePollutingKeys)[number];
|
|
236
|
+
declare function isPrototypePollutingKey(key: string): key is PrototypePollutingKey;
|
|
237
|
+
|
|
238
|
+
declare const handleOverrideByDelegation: (info: GraphQLResolveInfo$1, context: any, overrideHandler: OverrideHandler) => boolean;
|
|
239
|
+
|
|
240
|
+
export { type BatchingOptions, type CreateProxyingResolverFn, type Deferred, type DelegationContext, type DelegationPlanBuilder, type DelegationPlanLeftOver, EMPTY_ARRAY, EMPTY_OBJECT, type ExternalObject, FIELD_SUBSCHEMA_MAP_SYMBOL, type ICreateProxyingResolverOptions, type ICreateRequest, type IDelegateRequestOptions, type IDelegateToSchemaOptions, type MergedFieldConfig, type MergedTypeConfig, type MergedTypeEntryPoint, type MergedTypeInfo, type MergedTypeResolver, type MergedTypeResolverOptions, OBJECT_SUBSCHEMA_SYMBOL, type OverrideHandler, PLAN_LEFT_OVER, type RequestTransform, type ResultTransform, type SchemaTransform, type StitchingInfo, Subschema, type SubschemaConfig, type Transform, Transformer, UNPATHED_ERRORS_SYMBOL, annotateExternalObject, applySchemaTransforms, cloneSubschemaConfig, createRequest, defaultMergedResolver, delegateRequest, delegateToSchema, extractUnavailableFields, extractUnavailableFieldsFromSelectionSet, getActualFieldNodes, getDelegatingOperation, getPlanLeftOverFromParent, getSubschema, getTypeInfo, getTypeInfoWithType, getUnpathedErrors, handleOverrideByDelegation, handleResolverResult, isExternalObject, isPrototypePollutingKey, isSubschema, isSubschemaConfig, leftOverByDelegationPlan, mergeFields, resolveExternalValue, subtractSelectionSets };
|