@graphql-tools/delegate 8.8.2-alpha-33fb2950.0 → 8.8.2-alpha-420b7771.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/cjs/checkResultAndHandleErrors.js +1 -1
- package/cjs/createRequest.js +1 -1
- package/cjs/defaultMergedResolver.js +1 -1
- package/cjs/delegateToSchema.js +1 -1
- package/cjs/finalizeGatewayRequest.js +1 -1
- package/cjs/getDocumentMetadata.js +1 -1
- package/cjs/mergeFields.js +1 -1
- package/cjs/prepareGatewayDocument.js +1 -1
- package/cjs/resolveExternalValue.js +1 -1
- package/esm/checkResultAndHandleErrors.js +1 -1
- package/esm/createRequest.js +1 -1
- package/esm/defaultMergedResolver.js +1 -1
- package/esm/delegateToSchema.js +1 -1
- package/esm/finalizeGatewayRequest.js +1 -1
- package/esm/getDocumentMetadata.js +1 -1
- package/esm/mergeFields.js +1 -1
- package/esm/prepareGatewayDocument.js +1 -1
- package/esm/resolveExternalValue.js +1 -1
- package/package.json +9 -7
- package/typings/Subschema.d.cts +19 -0
- package/typings/Subschema.d.ts +1 -1
- package/typings/Transformer.d.cts +10 -0
- package/typings/applySchemaTransforms.d.cts +3 -0
- package/typings/applySchemaTransforms.d.ts +1 -1
- package/typings/checkResultAndHandleErrors.d.cts +8 -0
- package/typings/checkResultAndHandleErrors.d.ts +1 -1
- package/typings/createRequest.d.cts +5 -0
- package/typings/createRequest.d.ts +1 -1
- package/typings/defaultMergedResolver.d.cts +9 -0
- package/typings/defaultMergedResolver.d.ts +1 -1
- package/typings/delegateToSchema.d.cts +6 -0
- package/typings/delegateToSchema.d.ts +1 -1
- package/typings/finalizeGatewayRequest.d.cts +3 -0
- package/typings/getDocumentMetadata.d.cts +6 -0
- package/typings/getDocumentMetadata.d.ts +1 -1
- package/typings/index.d.cts +10 -0
- package/typings/mergeFields.d.cts +8 -0
- package/typings/mergeFields.d.ts +1 -1
- package/typings/prepareGatewayDocument.d.cts +2 -0
- package/typings/prepareGatewayDocument.d.ts +1 -1
- package/typings/resolveExternalValue.d.cts +3 -0
- package/typings/resolveExternalValue.d.ts +1 -1
- package/typings/subschemaConfig.d.cts +3 -0
- package/typings/symbols.d.cts +3 -0
- package/typings/types.d.cts +139 -0
- package/typings/types.d.ts +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeDataAndErrors = exports.checkResultAndHandleErrors = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
const resolveExternalValue_js_1 = require("./resolveExternalValue.js");
|
|
7
7
|
function checkResultAndHandleErrors(result, delegationContext) {
|
package/cjs/createRequest.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRequest = exports.getDelegatingOperation = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
function getDelegatingOperation(parentType, schema) {
|
|
7
7
|
if (parentType === schema.getMutationType()) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.defaultMergedResolver = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
const resolveExternalValue_js_1 = require("./resolveExternalValue.js");
|
|
7
7
|
const mergeFields_js_1 = require("./mergeFields.js");
|
package/cjs/delegateToSchema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDefaultExecutor = exports.delegateRequest = exports.delegateToSchema = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const value_or_promise_1 = require("value-or-promise");
|
|
6
6
|
const batch_execute_1 = require("@graphql-tools/batch-execute");
|
|
7
7
|
const utils_1 = require("@graphql-tools/utils");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.finalizeGatewayRequest = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
const getDocumentMetadata_js_1 = require("./getDocumentMetadata.js");
|
|
7
7
|
function finalizeGatewayDocument(targetSchema, fragments, operations) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getDocumentMetadata = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
function getDocumentMetadata(document) {
|
|
6
6
|
const operations = [];
|
|
7
7
|
const fragments = [];
|
package/cjs/mergeFields.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.mergeFields = exports.getUnpathedErrors = exports.getSubschema = exports.annotateExternalObject = exports.isExternalObject = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
const symbols_js_1 = require("./symbols.js");
|
|
7
7
|
function isExternalObject(data) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.prepareGatewayDocument = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
const getDocumentMetadata_js_1 = require("./getDocumentMetadata.js");
|
|
7
7
|
function prepareGatewayDocument(originalDocument, transformedSchema, returnType, infoSchema) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveExternalValue = void 0;
|
|
4
|
-
const graphql_1 = require("
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
5
|
const utils_1 = require("@graphql-tools/utils");
|
|
6
6
|
const mergeFields_js_1 = require("./mergeFields.js");
|
|
7
7
|
function resolveExternalValue(result, unpathedErrors, subschema, context, info, returnType = getReturnType(info), skipTypeMerging) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { responsePathAsArray, locatedError
|
|
1
|
+
import { responsePathAsArray, locatedError } from 'graphql';
|
|
2
2
|
import { AggregateError, getResponseKeyFromInfo, relocatedError } from '@graphql-tools/utils';
|
|
3
3
|
import { resolveExternalValue } from './resolveExternalValue.js';
|
|
4
4
|
export function checkResultAndHandleErrors(result, delegationContext) {
|
package/esm/createRequest.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kind, typeFromAST, } from '
|
|
1
|
+
import { Kind, typeFromAST, } from 'graphql';
|
|
2
2
|
import { createVariableNameGenerator, serializeInputValue, updateArgument, } from '@graphql-tools/utils';
|
|
3
3
|
export function getDelegatingOperation(parentType, schema) {
|
|
4
4
|
if (parentType === schema.getMutationType()) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defaultFieldResolver } from '
|
|
1
|
+
import { defaultFieldResolver } from 'graphql';
|
|
2
2
|
import { getResponseKeyFromInfo } from '@graphql-tools/utils';
|
|
3
3
|
import { resolveExternalValue } from './resolveExternalValue.js';
|
|
4
4
|
import { getSubschema, getUnpathedErrors, isExternalObject } from './mergeFields.js';
|
package/esm/delegateToSchema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { validate, subscribe, execute, } from '
|
|
1
|
+
import { validate, subscribe, execute, } from 'graphql';
|
|
2
2
|
import { ValueOrPromise } from 'value-or-promise';
|
|
3
3
|
import { getBatchingExecutor } from '@graphql-tools/batch-execute';
|
|
4
4
|
import { mapAsyncIterator, AggregateError, isAsyncIterable, getDefinedRootType, memoize1, getOperationASTFromRequest, } from '@graphql-tools/utils';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNamedType, isAbstractType, isInterfaceType, isObjectType, Kind, TypeInfo, TypeNameMetaFieldDef, versionInfo as graphqlVersionInfo, visit, visitWithTypeInfo, } from '
|
|
1
|
+
import { getNamedType, isAbstractType, isInterfaceType, isObjectType, Kind, TypeInfo, TypeNameMetaFieldDef, versionInfo as graphqlVersionInfo, visit, visitWithTypeInfo, } from 'graphql';
|
|
2
2
|
import { getDefinedRootType, serializeInputValue, updateArgument, createVariableNameGenerator, implementsAbstractType, inspect, } from '@graphql-tools/utils';
|
|
3
3
|
import { getDocumentMetadata } from './getDocumentMetadata.js';
|
|
4
4
|
function finalizeGatewayDocument(targetSchema, fragments, operations) {
|
package/esm/mergeFields.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { responsePathAsArray, GraphQLError, locatedError, } from '
|
|
1
|
+
import { responsePathAsArray, GraphQLError, locatedError, } from 'graphql';
|
|
2
2
|
import { collectFields, relocatedError } from '@graphql-tools/utils';
|
|
3
3
|
import { FIELD_SUBSCHEMA_MAP_SYMBOL, OBJECT_SUBSCHEMA_SYMBOL, UNPATHED_ERRORS_SYMBOL } from './symbols.js';
|
|
4
4
|
export function isExternalObject(data) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Kind, TypeInfo, getNamedType, isAbstractType, isInterfaceType, visit, visitWithTypeInfo, isObjectType, } from '
|
|
1
|
+
import { Kind, TypeInfo, getNamedType, isAbstractType, isInterfaceType, visit, visitWithTypeInfo, isObjectType, } from 'graphql';
|
|
2
2
|
import { implementsAbstractType, getRootTypeNames, memoize2 } from '@graphql-tools/utils';
|
|
3
3
|
import { getDocumentMetadata } from './getDocumentMetadata.js';
|
|
4
4
|
export function prepareGatewayDocument(originalDocument, transformedSchema, returnType, infoSchema) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getNullableType, isCompositeType, isListType, isAbstractType, locatedError, } from '
|
|
1
|
+
import { getNullableType, isCompositeType, isListType, isAbstractType, locatedError, } from 'graphql';
|
|
2
2
|
import { AggregateError } from '@graphql-tools/utils';
|
|
3
3
|
import { annotateExternalObject, isExternalObject, mergeFields } from './mergeFields.js';
|
|
4
4
|
export function resolveExternalValue(result, unpathedErrors, subschema, context, info, returnType = getReturnType(info), skipTypeMerging) {
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-tools/delegate",
|
|
3
|
-
"version": "8.8.2-alpha-
|
|
3
|
+
"version": "8.8.2-alpha-420b7771.0",
|
|
4
4
|
"description": "A set of utils for faster development of GraphQL tools",
|
|
5
5
|
"sideEffects": false,
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0"
|
|
8
|
+
},
|
|
6
9
|
"dependencies": {
|
|
7
|
-
"@graphql-tools/batch-execute": "8.5.2-alpha-
|
|
8
|
-
"@graphql-tools/schema": "8.5.2-alpha-
|
|
9
|
-
"@graphql-tools/utils": "8.9.1-alpha-
|
|
10
|
-
"@graphql-tools/graphql": "0.1.0-alpha-33fb2950.0",
|
|
10
|
+
"@graphql-tools/batch-execute": "8.5.2-alpha-420b7771.0",
|
|
11
|
+
"@graphql-tools/schema": "8.5.2-alpha-420b7771.0",
|
|
12
|
+
"@graphql-tools/utils": "8.9.1-alpha-420b7771.0",
|
|
11
13
|
"dataloader": "2.1.0",
|
|
12
14
|
"tslib": "~2.4.0",
|
|
13
15
|
"value-or-promise": "1.0.11"
|
|
@@ -28,7 +30,7 @@
|
|
|
28
30
|
"exports": {
|
|
29
31
|
".": {
|
|
30
32
|
"require": {
|
|
31
|
-
"types": "./typings/index.d.
|
|
33
|
+
"types": "./typings/index.d.cts",
|
|
32
34
|
"default": "./cjs/index.js"
|
|
33
35
|
},
|
|
34
36
|
"import": {
|
|
@@ -42,7 +44,7 @@
|
|
|
42
44
|
},
|
|
43
45
|
"./*": {
|
|
44
46
|
"require": {
|
|
45
|
-
"types": "./typings/*.d.
|
|
47
|
+
"types": "./typings/*.d.cts",
|
|
46
48
|
"default": "./cjs/*.js"
|
|
47
49
|
},
|
|
48
50
|
"import": {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, BatchingOptions } from './types.js';
|
|
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/typings/Subschema.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema } from '
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { SubschemaConfig, Transform, MergedTypeConfig, CreateProxyingResolverFn, BatchingOptions } from './types.js';
|
|
3
3
|
import { Executor } from '@graphql-tools/utils';
|
|
4
4
|
export declare function isSubschema(value: any): value is Subschema;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExecutionRequest, ExecutionResult } from '@graphql-tools/utils';
|
|
2
|
+
import { DelegationContext } from './types.js';
|
|
3
|
+
export declare class Transformer<TContext extends Record<string, any> = 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
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { SubschemaConfig } from './types.js';
|
|
3
|
+
export declare function applySchemaTransforms(originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, any>, transformedSchema?: GraphQLSchema): GraphQLSchema;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { GraphQLSchema } from '
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { SubschemaConfig } from './types.js';
|
|
3
3
|
export declare function applySchemaTransforms(originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, any>, transformedSchema?: GraphQLSchema): GraphQLSchema;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
|
+
import { ExecutionResult } from '@graphql-tools/utils';
|
|
3
|
+
import { DelegationContext } from './types.js';
|
|
4
|
+
export declare function checkResultAndHandleErrors<TContext extends Record<string, any>>(result: ExecutionResult, delegationContext: DelegationContext<TContext>): 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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLError } from '
|
|
1
|
+
import { GraphQLError } from 'graphql';
|
|
2
2
|
import { ExecutionResult } from '@graphql-tools/utils';
|
|
3
3
|
import { DelegationContext } from './types.js';
|
|
4
4
|
export declare function checkResultAndHandleErrors<TContext extends Record<string, any>>(result: ExecutionResult, delegationContext: DelegationContext<TContext>): any;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GraphQLSchema, GraphQLObjectType, OperationTypeNode } from 'graphql';
|
|
2
|
+
import { ExecutionRequest } from '@graphql-tools/utils';
|
|
3
|
+
import { ICreateRequest } from './types.js';
|
|
4
|
+
export declare function getDelegatingOperation(parentType: GraphQLObjectType, schema: GraphQLSchema): OperationTypeNode;
|
|
5
|
+
export declare function createRequest({ sourceSchema, sourceParentType, sourceFieldName, fragments, variableDefinitions, variableValues, targetRootValue, targetOperationName, targetOperation, targetFieldName, selectionSet, fieldNodes, context, info, }: ICreateRequest): ExecutionRequest;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLObjectType, OperationTypeNode } from '
|
|
1
|
+
import { GraphQLSchema, GraphQLObjectType, OperationTypeNode } from 'graphql';
|
|
2
2
|
import { ExecutionRequest } from '@graphql-tools/utils';
|
|
3
3
|
import { ICreateRequest } from './types.js';
|
|
4
4
|
export declare function getDelegatingOperation(parentType: GraphQLObjectType, schema: GraphQLSchema): OperationTypeNode;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { GraphQLResolveInfo } from 'graphql';
|
|
2
|
+
import { ExternalObject } from './types.js';
|
|
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;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
|
+
import { Executor } from '@graphql-tools/utils';
|
|
3
|
+
import { IDelegateToSchemaOptions, IDelegateRequestOptions } from './types.js';
|
|
4
|
+
export declare function delegateToSchema<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateToSchemaOptions<TContext, TArgs>): any;
|
|
5
|
+
export declare function delegateRequest<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateRequestOptions<TContext, TArgs>): any;
|
|
6
|
+
export declare const createDefaultExecutor: (schema: GraphQLSchema) => Executor;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema } from '
|
|
1
|
+
import { GraphQLSchema } from 'graphql';
|
|
2
2
|
import { Executor } from '@graphql-tools/utils';
|
|
3
3
|
import { IDelegateToSchemaOptions, IDelegateRequestOptions } from './types.js';
|
|
4
4
|
export declare function delegateToSchema<TContext extends Record<string, any> = Record<string, any>, TArgs extends Record<string, any> = any>(options: IDelegateToSchemaOptions<TContext, TArgs>): any;
|
|
@@ -0,0 +1,6 @@
|
|
|
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
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DocumentNode, FragmentDefinitionNode, OperationDefinitionNode } from '
|
|
1
|
+
import { DocumentNode, FragmentDefinitionNode, OperationDefinitionNode } from 'graphql';
|
|
2
2
|
export declare function getDocumentMetadata(document: DocumentNode): {
|
|
3
3
|
operations: Array<OperationDefinitionNode>;
|
|
4
4
|
fragments: Array<FragmentDefinitionNode>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './Subschema.js';
|
|
2
|
+
export * from './Transformer.js';
|
|
3
|
+
export * from './applySchemaTransforms.js';
|
|
4
|
+
export * from './createRequest.js';
|
|
5
|
+
export * from './defaultMergedResolver.js';
|
|
6
|
+
export * from './delegateToSchema.js';
|
|
7
|
+
export * from './mergeFields.js';
|
|
8
|
+
export * from './resolveExternalValue.js';
|
|
9
|
+
export * from './subschemaConfig.js';
|
|
10
|
+
export * from './types.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema } from 'graphql';
|
|
2
|
+
import { ExternalObject, MergedTypeInfo, SubschemaConfig } from './types.js';
|
|
3
|
+
import { Subschema } from './Subschema.js';
|
|
4
|
+
export declare function isExternalObject(data: any): data is ExternalObject;
|
|
5
|
+
export 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;
|
|
6
|
+
export declare function getSubschema(object: ExternalObject, responseKey: string): GraphQLSchema | SubschemaConfig;
|
|
7
|
+
export declare function getUnpathedErrors(object: ExternalObject): Array<GraphQLError>;
|
|
8
|
+
export declare function mergeFields<TContext>(mergedTypeInfo: MergedTypeInfo, object: any, sourceSubschema: Subschema<any, any, any, TContext>, context: any, info: GraphQLResolveInfo): Promise<any>;
|
package/typings/mergeFields.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema } from '
|
|
1
|
+
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema } from 'graphql';
|
|
2
2
|
import { ExternalObject, MergedTypeInfo, SubschemaConfig } from './types.js';
|
|
3
3
|
import { Subschema } from './Subschema.js';
|
|
4
4
|
export declare function isExternalObject(data: any): data is ExternalObject;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DocumentNode, GraphQLSchema, GraphQLOutputType } from '
|
|
1
|
+
import { DocumentNode, GraphQLSchema, GraphQLOutputType } from 'graphql';
|
|
2
2
|
export declare function prepareGatewayDocument(originalDocument: DocumentNode, transformedSchema: GraphQLSchema, returnType: GraphQLOutputType, infoSchema?: GraphQLSchema): DocumentNode;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema, GraphQLOutputType } from 'graphql';
|
|
2
|
+
import { SubschemaConfig } from './types.js';
|
|
3
|
+
export 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;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema, GraphQLOutputType } from '
|
|
1
|
+
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema, GraphQLOutputType } from 'graphql';
|
|
2
2
|
import { SubschemaConfig } from './types.js';
|
|
3
3
|
export 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;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { GraphQLSchema, GraphQLOutputType, SelectionSetNode, FieldNode, GraphQLResolveInfo, GraphQLFieldResolver, FragmentDefinitionNode, GraphQLObjectType, VariableDefinitionNode, OperationTypeNode, GraphQLError, GraphQLNamedType } from 'graphql';
|
|
2
|
+
import DataLoader from 'dataloader';
|
|
3
|
+
import { ExecutionRequest, ExecutionResult, Executor } from '@graphql-tools/utils';
|
|
4
|
+
import { Subschema } from './Subschema.js';
|
|
5
|
+
import { OBJECT_SUBSCHEMA_SYMBOL, FIELD_SUBSCHEMA_MAP_SYMBOL, UNPATHED_ERRORS_SYMBOL } from './symbols.js';
|
|
6
|
+
export declare type SchemaTransform<TContext = Record<any, string>> = (originalWrappingSchema: GraphQLSchema, subschemaConfig: SubschemaConfig<any, any, any, TContext>, transformedSchema?: GraphQLSchema) => GraphQLSchema;
|
|
7
|
+
export declare type RequestTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalRequest: ExecutionRequest, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionRequest;
|
|
8
|
+
export declare type ResultTransform<T = Record<string, any>, TContext = Record<any, string>> = (originalResult: ExecutionResult, delegationContext: DelegationContext<TContext>, transformationContext: T) => ExecutionResult;
|
|
9
|
+
export interface Transform<T = any, TContext = Record<string, any>> {
|
|
10
|
+
transformSchema?: SchemaTransform<TContext>;
|
|
11
|
+
transformRequest?: RequestTransform<T, TContext>;
|
|
12
|
+
transformResult?: ResultTransform<T, TContext>;
|
|
13
|
+
}
|
|
14
|
+
export interface DelegationContext<TContext = Record<string, any>> {
|
|
15
|
+
subschema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
16
|
+
subschemaConfig?: SubschemaConfig<any, any, any, TContext>;
|
|
17
|
+
targetSchema: GraphQLSchema;
|
|
18
|
+
operation: OperationTypeNode;
|
|
19
|
+
fieldName: string;
|
|
20
|
+
args?: Record<string, any>;
|
|
21
|
+
context?: TContext;
|
|
22
|
+
info?: GraphQLResolveInfo;
|
|
23
|
+
returnType: GraphQLOutputType;
|
|
24
|
+
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
25
|
+
rootValue?: any;
|
|
26
|
+
transforms: Array<Transform<any, TContext>>;
|
|
27
|
+
transformedSchema: GraphQLSchema;
|
|
28
|
+
skipTypeMerging: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface IDelegateToSchemaOptions<TContext = Record<string, any>, TArgs = Record<string, any>> {
|
|
31
|
+
schema: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
32
|
+
operationName?: string;
|
|
33
|
+
operation?: OperationTypeNode;
|
|
34
|
+
fieldName?: string;
|
|
35
|
+
returnType?: GraphQLOutputType;
|
|
36
|
+
onLocatedError?: (originalError: GraphQLError) => GraphQLError;
|
|
37
|
+
args?: TArgs;
|
|
38
|
+
selectionSet?: SelectionSetNode;
|
|
39
|
+
fieldNodes?: ReadonlyArray<FieldNode>;
|
|
40
|
+
context?: TContext;
|
|
41
|
+
info: GraphQLResolveInfo;
|
|
42
|
+
rootValue?: any;
|
|
43
|
+
transforms?: Array<Transform<any, TContext>>;
|
|
44
|
+
transformedSchema?: GraphQLSchema;
|
|
45
|
+
validateRequest?: boolean;
|
|
46
|
+
skipTypeMerging?: boolean;
|
|
47
|
+
}
|
|
48
|
+
export interface IDelegateRequestOptions<TContext = Record<string, any>, TArgs = Record<string, any>> extends IDelegateToSchemaOptions<TContext, TArgs> {
|
|
49
|
+
request: ExecutionRequest;
|
|
50
|
+
}
|
|
51
|
+
export interface ICreateRequest {
|
|
52
|
+
sourceSchema?: GraphQLSchema;
|
|
53
|
+
sourceParentType?: GraphQLObjectType;
|
|
54
|
+
sourceFieldName?: string;
|
|
55
|
+
fragments?: Record<string, FragmentDefinitionNode>;
|
|
56
|
+
variableDefinitions?: ReadonlyArray<VariableDefinitionNode>;
|
|
57
|
+
variableValues?: Record<string, any>;
|
|
58
|
+
targetOperation: OperationTypeNode;
|
|
59
|
+
targetRootValue?: any;
|
|
60
|
+
targetOperationName?: string;
|
|
61
|
+
targetFieldName: string;
|
|
62
|
+
selectionSet?: SelectionSetNode;
|
|
63
|
+
fieldNodes?: ReadonlyArray<FieldNode>;
|
|
64
|
+
context?: any;
|
|
65
|
+
info?: GraphQLResolveInfo;
|
|
66
|
+
}
|
|
67
|
+
export declare type DelegationPlanBuilder = (schema: GraphQLSchema, sourceSubschema: Subschema<any, any, any, any>, variableValues: Record<string, any>, fragments: Record<string, FragmentDefinitionNode>, fieldNodes: FieldNode[]) => Array<Map<Subschema, SelectionSetNode>>;
|
|
68
|
+
export interface MergedTypeInfo<TContext = Record<string, any>> {
|
|
69
|
+
typeName: string;
|
|
70
|
+
selectionSet?: SelectionSetNode;
|
|
71
|
+
targetSubschemas: Map<Subschema<any, any, any, TContext>, Array<Subschema<any, any, any, TContext>>>;
|
|
72
|
+
uniqueFields: Record<string, Subschema<any, any, any, TContext>>;
|
|
73
|
+
nonUniqueFields: Record<string, Array<Subschema<any, any, any, TContext>>>;
|
|
74
|
+
typeMaps: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Record<string, GraphQLNamedType>>;
|
|
75
|
+
selectionSets: Map<Subschema<any, any, any, TContext>, SelectionSetNode>;
|
|
76
|
+
fieldSelectionSets: Map<Subschema<any, any, any, TContext>, Record<string, SelectionSetNode>>;
|
|
77
|
+
resolvers: Map<Subschema<any, any, any, TContext>, MergedTypeResolver<TContext>>;
|
|
78
|
+
delegationPlanBuilder: DelegationPlanBuilder;
|
|
79
|
+
}
|
|
80
|
+
export interface ICreateProxyingResolverOptions<TContext = Record<string, any>> {
|
|
81
|
+
subschemaConfig: SubschemaConfig<any, any, any, TContext>;
|
|
82
|
+
transformedSchema?: GraphQLSchema;
|
|
83
|
+
operation?: OperationTypeNode;
|
|
84
|
+
fieldName?: string;
|
|
85
|
+
}
|
|
86
|
+
export declare type CreateProxyingResolverFn<TContext = Record<string, any>> = (options: ICreateProxyingResolverOptions<TContext>) => GraphQLFieldResolver<any, TContext>;
|
|
87
|
+
export interface BatchingOptions<K = any, V = any, C = K> {
|
|
88
|
+
extensionsReducer?: (mergedExtensions: Record<string, any>, request: ExecutionRequest) => Record<string, any>;
|
|
89
|
+
dataLoaderOptions?: DataLoader.Options<K, V, C>;
|
|
90
|
+
}
|
|
91
|
+
export interface SubschemaConfig<K = any, V = any, C = K, TContext = Record<string, any>> {
|
|
92
|
+
schema: GraphQLSchema;
|
|
93
|
+
createProxyingResolver?: CreateProxyingResolverFn<TContext>;
|
|
94
|
+
rootValue?: any;
|
|
95
|
+
transforms?: Array<Transform<any, TContext>>;
|
|
96
|
+
merge?: Record<string, MergedTypeConfig<any, any, TContext>>;
|
|
97
|
+
executor?: Executor<TContext>;
|
|
98
|
+
batch?: boolean;
|
|
99
|
+
batchingOptions?: BatchingOptions<K, V, C>;
|
|
100
|
+
}
|
|
101
|
+
export interface MergedTypeConfig<K = any, V = any, TContext = Record<string, any>> extends MergedTypeEntryPoint<K, V, TContext> {
|
|
102
|
+
entryPoints?: Array<MergedTypeEntryPoint>;
|
|
103
|
+
fields?: Record<string, MergedFieldConfig>;
|
|
104
|
+
computedFields?: Record<string, {
|
|
105
|
+
selectionSet?: string;
|
|
106
|
+
}>;
|
|
107
|
+
canonical?: boolean;
|
|
108
|
+
}
|
|
109
|
+
export interface MergedTypeEntryPoint<K = any, V = any, TContext = Record<string, any>> extends MergedTypeResolverOptions<K, V> {
|
|
110
|
+
selectionSet?: string;
|
|
111
|
+
key?: (originalResult: any) => K | PromiseLike<K>;
|
|
112
|
+
resolve?: MergedTypeResolver<TContext>;
|
|
113
|
+
}
|
|
114
|
+
export interface MergedTypeResolverOptions<K = any, V = any> {
|
|
115
|
+
fieldName?: string;
|
|
116
|
+
args?: (originalResult: any) => Record<string, any>;
|
|
117
|
+
argsFromKeys?: (keys: ReadonlyArray<K>) => Record<string, any>;
|
|
118
|
+
valuesFromResults?: (results: any, keys: ReadonlyArray<K>) => Array<V>;
|
|
119
|
+
}
|
|
120
|
+
export interface MergedFieldConfig {
|
|
121
|
+
selectionSet?: string;
|
|
122
|
+
computed?: boolean;
|
|
123
|
+
canonical?: boolean;
|
|
124
|
+
}
|
|
125
|
+
export declare 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;
|
|
126
|
+
export interface StitchingInfo<TContext = Record<string, any>> {
|
|
127
|
+
subschemaMap: Map<GraphQLSchema | SubschemaConfig<any, any, any, TContext>, Subschema<any, any, any, TContext>>;
|
|
128
|
+
fieldNodesByType: Record<string, Array<FieldNode>>;
|
|
129
|
+
fieldNodesByField: Record<string, Record<string, Array<FieldNode>>>;
|
|
130
|
+
dynamicSelectionSetsByField: Record<string, Record<string, Array<(node: FieldNode) => SelectionSetNode>>>;
|
|
131
|
+
mergedTypes: Record<string, MergedTypeInfo<TContext>>;
|
|
132
|
+
}
|
|
133
|
+
export interface ExternalObject<TContext = Record<string, any>> {
|
|
134
|
+
__typename: string;
|
|
135
|
+
key: any;
|
|
136
|
+
[OBJECT_SUBSCHEMA_SYMBOL]: GraphQLSchema | SubschemaConfig<any, any, any, TContext>;
|
|
137
|
+
[FIELD_SUBSCHEMA_MAP_SYMBOL]: Record<string, GraphQLSchema | SubschemaConfig<any, any, any, TContext>>;
|
|
138
|
+
[UNPATHED_ERRORS_SYMBOL]: Array<GraphQLError>;
|
|
139
|
+
}
|
package/typings/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLSchema, GraphQLOutputType, SelectionSetNode, FieldNode, GraphQLResolveInfo, GraphQLFieldResolver, FragmentDefinitionNode, GraphQLObjectType, VariableDefinitionNode, OperationTypeNode, GraphQLError, GraphQLNamedType } from '
|
|
1
|
+
import { GraphQLSchema, GraphQLOutputType, SelectionSetNode, FieldNode, GraphQLResolveInfo, GraphQLFieldResolver, FragmentDefinitionNode, GraphQLObjectType, VariableDefinitionNode, OperationTypeNode, GraphQLError, GraphQLNamedType } from 'graphql';
|
|
2
2
|
import DataLoader from 'dataloader';
|
|
3
3
|
import { ExecutionRequest, ExecutionResult, Executor } from '@graphql-tools/utils';
|
|
4
4
|
import { Subschema } from './Subschema.js';
|