@graphql-tools/delegate 8.2.2-alpha-5d885fa3.0 → 9.0.0-alpha-881b29e4.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/Subschema.d.ts +2 -6
- package/Transformer.d.ts +1 -1
- package/defaultMergedResolver.d.ts +3 -1
- package/delegateToSchema.d.ts +5 -2
- package/externalObjects.d.ts +11 -0
- package/externalValues.d.ts +4 -0
- package/getMergedParent.d.ts +9 -0
- package/index.d.ts +3 -2
- package/index.js +631 -305
- package/index.mjs +620 -306
- package/mergeDataAndErrors.d.ts +5 -0
- package/package.json +4 -4
- package/symbols.d.ts +5 -1
- package/types.d.ts +21 -13
- package/checkResultAndHandleErrors.d.ts +0 -8
- package/es5/README.md +0 -7
- package/es5/Subschema.d.ts +0 -19
- package/es5/Transformer.d.ts +0 -10
- package/es5/applySchemaTransforms.d.ts +0 -3
- package/es5/checkResultAndHandleErrors.d.ts +0 -8
- package/es5/createRequest.d.ts +0 -6
- package/es5/defaultMergedResolver.d.ts +0 -9
- package/es5/delegateToSchema.d.ts +0 -6
- package/es5/finalizeGatewayRequest.d.ts +0 -3
- package/es5/getDocumentMetadata.d.ts +0 -6
- package/es5/index.d.ts +0 -10
- package/es5/index.js +0 -1694
- package/es5/index.mjs +0 -1672
- package/es5/mergeFields.d.ts +0 -8
- package/es5/package.json +0 -39
- package/es5/prepareGatewayDocument.d.ts +0 -2
- package/es5/resolveExternalValue.d.ts +0 -3
- package/es5/subschemaConfig.d.ts +0 -3
- package/es5/symbols.d.ts +0 -3
- package/es5/types.d.ts +0 -149
- package/mergeFields.d.ts +0 -8
- package/resolveExternalValue.d.ts +0 -3
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
export declare function mergeDataAndErrors(data: any, errors?: ReadonlyArray<GraphQLError>, onLocatedError?: (originalError: GraphQLError) => GraphQLError, index?: number): {
|
|
3
|
+
data: any;
|
|
4
|
+
unpathedErrors: Array<GraphQLError>;
|
|
5
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/delegate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.0-alpha-881b29e4.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@graphql-tools/batch-execute": "
|
|
11
|
-
"@graphql-tools/schema": "8.2.1-alpha-
|
|
12
|
-
"@graphql-tools/utils": "
|
|
10
|
+
"@graphql-tools/batch-execute": "8.1.1-alpha-881b29e4.0",
|
|
11
|
+
"@graphql-tools/schema": "8.2.1-alpha-881b29e4.0",
|
|
12
|
+
"@graphql-tools/utils": "9.0.0-alpha-881b29e4.0",
|
|
13
13
|
"dataloader": "2.0.0",
|
|
14
14
|
"tslib": "~2.3.0",
|
|
15
15
|
"value-or-promise": "1.0.10"
|
package/symbols.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export declare const INITIAL_PATH_SYMBOL: unique symbol;
|
|
1
2
|
export declare const UNPATHED_ERRORS_SYMBOL: unique symbol;
|
|
2
3
|
export declare const OBJECT_SUBSCHEMA_SYMBOL: unique symbol;
|
|
3
|
-
export declare const
|
|
4
|
+
export declare const INITIAL_POSSIBLE_FIELDS: unique symbol;
|
|
5
|
+
export declare const INFO_SYMBOL: unique symbol;
|
|
6
|
+
export declare const RESPONSE_KEY_SUBSCHEMA_MAP_SYMBOL: unique symbol;
|
|
7
|
+
export declare const RECEIVER_MAP_SYMBOL: unique symbol;
|
package/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLOutputType, SelectionSetNode, FieldNode, GraphQLResolveInfo, GraphQLFieldResolver, FragmentDefinitionNode, GraphQLObjectType, VariableDefinitionNode, OperationTypeNode, GraphQLError, GraphQLNamedType } from 'graphql';
|
|
1
|
+
import { GraphQLSchema, GraphQLOutputType, SelectionSetNode, FieldNode, GraphQLResolveInfo, GraphQLFieldResolver, FragmentDefinitionNode, GraphQLObjectType, VariableDefinitionNode, OperationTypeNode, GraphQLError, GraphQLNamedType, GraphQLFieldMap } from 'graphql';
|
|
2
2
|
import DataLoader from 'dataloader';
|
|
3
3
|
import { ExecutionRequest, ExecutionResult, Executor } from '@graphql-tools/utils';
|
|
4
4
|
import { Subschema } from './Subschema';
|
|
5
|
-
import { OBJECT_SUBSCHEMA_SYMBOL,
|
|
5
|
+
import { INFO_SYMBOL, INITIAL_PATH_SYMBOL, INITIAL_POSSIBLE_FIELDS, OBJECT_SUBSCHEMA_SYMBOL, RESPONSE_KEY_SUBSCHEMA_MAP_SYMBOL, UNPATHED_ERRORS_SYMBOL } from './symbols';
|
|
6
6
|
export declare type SchemaTransform<TContext = Record<any, string>> = (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, TContext>, transformedSchema?: GraphQLSchema) => GraphQLSchema;
|
|
7
7
|
export declare type RequestTransform<T = Record<string, any>> = (originalRequest: ExecutionRequest, delegationContext: DelegationContext, transformationContext: T) => ExecutionRequest;
|
|
8
8
|
export declare type ResultTransform<T = Record<string, any>> = (originalResult: ExecutionResult, delegationContext: DelegationContext, transformationContext: T) => ExecutionResult;
|
|
@@ -21,11 +21,9 @@ export interface DelegationContext<TContext = Record<string, any>> {
|
|
|
21
21
|
context?: TContext;
|
|
22
22
|
info?: GraphQLResolveInfo;
|
|
23
23
|
returnType: GraphQLOutputType;
|
|
24
|
-
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
25
24
|
rootValue?: any;
|
|
26
25
|
transforms: Array<Transform<any, TContext>>;
|
|
27
26
|
transformedSchema: GraphQLSchema;
|
|
28
|
-
skipTypeMerging: boolean;
|
|
29
27
|
}
|
|
30
28
|
export interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs = Record<string, any>> {
|
|
31
29
|
schema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
@@ -43,7 +41,6 @@ export interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs
|
|
|
43
41
|
transforms?: Array<Transform<any, TContext>>;
|
|
44
42
|
transformedSchema?: GraphQLSchema;
|
|
45
43
|
validateRequest?: boolean;
|
|
46
|
-
skipTypeMerging?: boolean;
|
|
47
44
|
}
|
|
48
45
|
export interface IDelegateRequestOptions<TContext = Record<string, any>, TArgs = Record<string, any>> extends IDelegateToSchemaOptions<TContext, TArgs> {
|
|
49
46
|
request: ExecutionRequest;
|
|
@@ -74,7 +71,15 @@ export interface ICreateRequest {
|
|
|
74
71
|
context?: any;
|
|
75
72
|
info?: GraphQLResolveInfo;
|
|
76
73
|
}
|
|
77
|
-
export
|
|
74
|
+
export interface ExternalValueFromResultOptions<TContext = Record<string, any>> {
|
|
75
|
+
result: ExecutionResult;
|
|
76
|
+
schema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
77
|
+
fieldName?: string;
|
|
78
|
+
context?: TContext;
|
|
79
|
+
info?: GraphQLResolveInfo;
|
|
80
|
+
returnType?: GraphQLOutputType;
|
|
81
|
+
onLocatedError?: (error: GraphQLError) => GraphQLError;
|
|
82
|
+
}
|
|
78
83
|
export interface MergedTypeInfo<TContext = Record<string, any>> {
|
|
79
84
|
typeName: string;
|
|
80
85
|
selectionSet?: SelectionSetNode;
|
|
@@ -82,10 +87,10 @@ export interface MergedTypeInfo<TContext = Record<string, any>> {
|
|
|
82
87
|
uniqueFields: Record<string, Subschema<any, any, any, TContext>>;
|
|
83
88
|
nonUniqueFields: Record<string, Array<Subschema<any, any, any, TContext>>>;
|
|
84
89
|
typeMaps: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Record<string, GraphQLNamedType>>;
|
|
90
|
+
subschemaFields: Record<string, boolean>;
|
|
85
91
|
selectionSets: Map<Subschema<any, any, any, TContext>, SelectionSetNode>;
|
|
86
92
|
fieldSelectionSets: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
|
|
87
93
|
resolvers: Map<Subschema<any, any, any, TContext>, MergedTypeResolver<TContext>>;
|
|
88
|
-
delegationPlanBuilder: DelegationPlanBuilder;
|
|
89
94
|
}
|
|
90
95
|
export interface ICreateProxyingResolverOptions<TContext = Record<string, any>> {
|
|
91
96
|
subschemaConfig: SubschemaConfig<any, any, any, TContext>;
|
|
@@ -103,12 +108,12 @@ export interface SubschemaConfig<K = any, V = any, C = K, TContext = Record<stri
|
|
|
103
108
|
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
104
109
|
rootValue?: any;
|
|
105
110
|
transforms?: Array<Transform<any, TContext>>;
|
|
106
|
-
merge?: Record<string, MergedTypeConfig<any,
|
|
111
|
+
merge?: Record<string, MergedTypeConfig<any, TContext>>;
|
|
107
112
|
executor?: Executor<TContext>;
|
|
108
113
|
batch?: boolean;
|
|
109
114
|
batchingOptions?: BatchingOptions<K, V, C>;
|
|
110
115
|
}
|
|
111
|
-
export interface MergedTypeConfig<K = any,
|
|
116
|
+
export interface MergedTypeConfig<K = any, TContext = Record<string, any>> extends MergedTypeEntryPoint<K, TContext> {
|
|
112
117
|
entryPoints?: Array<MergedTypeEntryPoint>;
|
|
113
118
|
fields?: Record<string, MergedFieldConfig>;
|
|
114
119
|
computedFields?: Record<string, {
|
|
@@ -116,16 +121,15 @@ export interface MergedTypeConfig<K = any, V = any, TContext = Record<string, an
|
|
|
116
121
|
}>;
|
|
117
122
|
canonical?: boolean;
|
|
118
123
|
}
|
|
119
|
-
export interface MergedTypeEntryPoint<K = any,
|
|
124
|
+
export interface MergedTypeEntryPoint<K = any, TContext = Record<string, any>> extends MergedTypeResolverOptions<K> {
|
|
120
125
|
selectionSet?: string;
|
|
121
126
|
key?: (originalResult: any) => K;
|
|
122
127
|
resolve?: MergedTypeResolver<TContext>;
|
|
123
128
|
}
|
|
124
|
-
export interface MergedTypeResolverOptions<K = any
|
|
129
|
+
export interface MergedTypeResolverOptions<K = any> {
|
|
125
130
|
fieldName?: string;
|
|
126
131
|
args?: (originalResult: any) => Record<string, any>;
|
|
127
132
|
argsFromKeys?: (keys: ReadonlyArray<K>) => Record<string, any>;
|
|
128
|
-
valuesFromResults?: (results: any, keys: ReadonlyArray<K>) => Array<V>;
|
|
129
133
|
}
|
|
130
134
|
export interface MergedFieldConfig {
|
|
131
135
|
selectionSet?: string;
|
|
@@ -143,7 +147,11 @@ export interface StitchingInfo<TContext = Record<string, any>> {
|
|
|
143
147
|
export interface ExternalObject<TContext = Record<string, any>> {
|
|
144
148
|
__typename: string;
|
|
145
149
|
key: any;
|
|
150
|
+
[UNPATHED_ERRORS_SYMBOL]: Array<GraphQLError>;
|
|
151
|
+
[INITIAL_PATH_SYMBOL]: Array<string | number>;
|
|
146
152
|
[OBJECT_SUBSCHEMA_SYMBOL]: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
147
|
-
[
|
|
153
|
+
[INITIAL_POSSIBLE_FIELDS]: GraphQLFieldMap<any, any>;
|
|
154
|
+
[INFO_SYMBOL]: GraphQLResolveInfo;
|
|
155
|
+
[RESPONSE_KEY_SUBSCHEMA_MAP_SYMBOL]: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, TContext>>;
|
|
148
156
|
[UNPATHED_ERRORS_SYMBOL]: Array<GraphQLError>;
|
|
149
157
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GraphQLError } from 'graphql';
|
|
2
|
-
import { ExecutionResult } from '@graphql-tools/utils';
|
|
3
|
-
import { DelegationContext } from './types';
|
|
4
|
-
export declare function checkResultAndHandleErrors(result: ExecutionResult, delegationContext: DelegationContext): any;
|
|
5
|
-
export declare function mergeDataAndErrors(data: any, errors: ReadonlyArray<GraphQLError>, path: Array<string | number> | undefined, onLocatedError?: (originalError: GraphQLError) => GraphQLError, index?: number): {
|
|
6
|
-
data: any;
|
|
7
|
-
unpathedErrors: Array<GraphQLError>;
|
|
8
|
-
};
|
package/es5/README.md
DELETED
package/es5/Subschema.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, BatchingOptions } from './types';
|
|
3
|
-
import { Executor } from '@graphql-tools/utils';
|
|
4
|
-
export declare function isSubschema(value: any): value is Subschema;
|
|
5
|
-
interface ISubschema<K = any, V = any, C = K, TContext = Record<string, any>> extends SubschemaConfig<K, V, C, TContext> {
|
|
6
|
-
transformedSchema: GraphQLSchema;
|
|
7
|
-
}
|
|
8
|
-
export declare class Subschema<K = any, V = any, C = K, TContext = Record<string, any>> implements ISubschema<K, V, C, TContext> {
|
|
9
|
-
schema: GraphQLSchema;
|
|
10
|
-
executor?: Executor<TContext>;
|
|
11
|
-
batch?: boolean;
|
|
12
|
-
batchingOptions?: BatchingOptions<K, V, C>;
|
|
13
|
-
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
14
|
-
transforms: Array<Transform<any, TContext>>;
|
|
15
|
-
transformedSchema: GraphQLSchema;
|
|
16
|
-
merge?: Record<string, MergedTypeConfig<any, any, TContext>>;
|
|
17
|
-
constructor(config: SubschemaConfig<K, V, C, TContext>);
|
|
18
|
-
}
|
|
19
|
-
export {};
|
package/es5/Transformer.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ExecutionRequest, ExecutionResult } from '@graphql-tools/utils';
|
|
2
|
-
import { DelegationContext } from './types';
|
|
3
|
-
export declare class Transformer<TContext = Record<string, any>> {
|
|
4
|
-
private transformations;
|
|
5
|
-
private delegationContext;
|
|
6
|
-
constructor(context: DelegationContext<TContext>);
|
|
7
|
-
private addTransform;
|
|
8
|
-
transformRequest(originalRequest: ExecutionRequest): ExecutionRequest;
|
|
9
|
-
transformResult(originalResult: ExecutionResult): any;
|
|
10
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { SubschemaConfig } from './types';
|
|
3
|
-
export declare function applySchemaTransforms(originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, any>, transformedSchema?: GraphQLSchema): GraphQLSchema;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GraphQLError } from 'graphql';
|
|
2
|
-
import { ExecutionResult } from '@graphql-tools/utils';
|
|
3
|
-
import { DelegationContext } from './types';
|
|
4
|
-
export declare function checkResultAndHandleErrors(result: ExecutionResult, delegationContext: DelegationContext): any;
|
|
5
|
-
export declare function mergeDataAndErrors(data: any, errors: ReadonlyArray<GraphQLError>, path: Array<string | number> | undefined, onLocatedError?: (originalError: GraphQLError) => GraphQLError, index?: number): {
|
|
6
|
-
data: any;
|
|
7
|
-
unpathedErrors: Array<GraphQLError>;
|
|
8
|
-
};
|
package/es5/createRequest.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLObjectType, OperationTypeNode } from 'graphql';
|
|
2
|
-
import { ExecutionRequest } from '@graphql-tools/utils';
|
|
3
|
-
import { ICreateRequestFromInfo, ICreateRequest } from './types';
|
|
4
|
-
export declare function getDelegatingOperation(parentType: GraphQLObjectType, schema: GraphQLSchema): OperationTypeNode;
|
|
5
|
-
export declare function createRequestFromInfo({ info, rootValue, operationName, operation, fieldName, selectionSet, fieldNodes, context, }: ICreateRequestFromInfo): ExecutionRequest;
|
|
6
|
-
export declare function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragments, variableDefinitions, variableValues, targetRootValue, targetOperationName, targetOperation, targetFieldName, selectionSet, fieldNodes, context, info, }: ICreateRequest): ExecutionRequest;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { GraphQLResolveInfo } from 'graphql';
|
|
2
|
-
import { ExternalObject } from './types';
|
|
3
|
-
/**
|
|
4
|
-
* Resolver that knows how to:
|
|
5
|
-
* a) handle aliases for proxied schemas
|
|
6
|
-
* b) handle errors from proxied schemas
|
|
7
|
-
* c) handle external to internal enum conversion
|
|
8
|
-
*/
|
|
9
|
-
export declare function defaultMergedResolver(parent: ExternalObject, args: Record<string, any>, context: Record<string, any>, info: GraphQLResolveInfo): any;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { GraphQLSchema } from 'graphql';
|
|
2
|
-
import { Executor } from '@graphql-tools/utils';
|
|
3
|
-
import { IDelegateToSchemaOptions, IDelegateRequestOptions } from './types';
|
|
4
|
-
export declare function delegateToSchema<TContext = Record<string, any>, TArgs = any>(options: IDelegateToSchemaOptions<TContext, TArgs>): any;
|
|
5
|
-
export declare function delegateRequest<TContext = Record<string, any>, TArgs = any>(options: IDelegateRequestOptions<TContext, TArgs>): any;
|
|
6
|
-
export declare const createDefaultExecutor: (schema: GraphQLSchema) => Executor;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DocumentNode, FragmentDefinitionNode, OperationDefinitionNode } from 'graphql';
|
|
2
|
-
export declare function getDocumentMetadata(document: DocumentNode): {
|
|
3
|
-
operations: Array<OperationDefinitionNode>;
|
|
4
|
-
fragments: Array<FragmentDefinitionNode>;
|
|
5
|
-
fragmentNames: Set<string>;
|
|
6
|
-
};
|
package/es5/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './Subschema';
|
|
2
|
-
export * from './Transformer';
|
|
3
|
-
export * from './applySchemaTransforms';
|
|
4
|
-
export * from './createRequest';
|
|
5
|
-
export * from './defaultMergedResolver';
|
|
6
|
-
export * from './delegateToSchema';
|
|
7
|
-
export * from './mergeFields';
|
|
8
|
-
export * from './resolveExternalValue';
|
|
9
|
-
export * from './subschemaConfig';
|
|
10
|
-
export * from './types';
|