New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-tools-fork

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-tools-fork - npm Package Compare versions

Comparing version 6.1.6 to 6.2.0

dist/stitching/delegateToRemoteSchema.d.ts

16

CHANGELOG.md

@@ -5,2 +5,18 @@ # Changelog

## [6.2.0](https://github.com/yaacovCR/graphql-tools-fork/compare/v6.1.6...v6.2.0) (2019-07-31)
### Bug Fixes
* **types:** export OnTypeConflict type ([fcc608b](https://github.com/yaacovCR/graphql-tools-fork/commit/fcc608b))
### Features
* **stitching:** allow delegateToSchema, mergeSchemas and transformSchema to take remote schema configurations as parameters ([12d2f5a](https://github.com/yaacovCR/graphql-tools-fork/commit/12d2f5a))
* **transformers:** TransformQuery transformer adds errorPathTransformer property to properly return errors from transformed queries. ([6159ad2](https://github.com/yaacovCR/graphql-tools-fork/commit/6159ad2))
* **transforms:** add dedicated filterSchema function to allow schema filtering without a layer of delegation ([8a50f38](https://github.com/yaacovCR/graphql-tools-fork/commit/8a50f38))
### [6.1.6](https://github.com/yaacovCR/graphql-tools-fork/compare/v6.1.5...v6.1.6) (2019-07-19)

@@ -7,0 +23,0 @@

1

dist/index.js

@@ -5,2 +5,3 @@ function __export(m) {

Object.defineProperty(exports, "__esModule", { value: true });
__export(require("./Interfaces"));
__export(require("./makeExecutableSchema"));

@@ -7,0 +8,0 @@ __export(require("./mock"));

@@ -1,3 +0,4 @@

import { GraphQLSchema, GraphQLField, ExecutionResult, GraphQLType, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLIsTypeOfFn, GraphQLTypeResolver, GraphQLScalarType, DocumentNode } from 'graphql';
import { GraphQLSchema, GraphQLField, ExecutionResult, GraphQLType, GraphQLNamedType, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLIsTypeOfFn, GraphQLTypeResolver, GraphQLScalarType, DocumentNode } from 'graphql';
import { SchemaDirectiveVisitor } from './schemaVisitor';
import { ApolloLink } from 'apollo-link';
export declare type UnitOrList<Type> = Type | Array<Type>;

@@ -32,2 +33,28 @@ export interface IResolverValidationOptions {

}
export declare type Fetcher = (operation: IFetcherOperation) => Promise<ExecutionResult>;
export interface IFetcherOperation {
query: DocumentNode;
operationName?: string;
variables?: {
[key: string]: any;
};
context?: {
[key: string]: any;
};
}
export declare type Dispatcher = (context: any) => ApolloLink | Fetcher;
export declare type SchemaExecutionConfig = {
schema: GraphQLSchemaWithTransforms;
};
export declare type GraphQLSchemaWithTransforms = GraphQLSchema & {
transforms?: Array<Transform>;
};
export declare type RemoteSchemaExecutionConfig = {
schema: GraphQLSchemaWithTransforms;
link?: ApolloLink;
fetcher?: Fetcher;
dispatcher?: Dispatcher;
};
export declare function isSchemaExecutionConfig(schema: string | GraphQLSchema | SchemaExecutionConfig | DocumentNode | Array<GraphQLNamedType>): schema is SchemaExecutionConfig;
export declare function isRemoteSchemaExecutionConfig(schema: GraphQLSchema | SchemaExecutionConfig): schema is RemoteSchemaExecutionConfig;
export interface IDelegateToSchemaOptions<TContext = {

@@ -46,3 +73,14 @@ [key: string]: any;

skipValidation?: boolean;
executor?: Delegator;
subscriber?: Delegator;
}
export declare type Delegator = ({ document, context, variables }: {
document: DocumentNode;
context?: {
[key: string]: any;
};
variables?: {
[key: string]: any;
};
}) => any;
export declare type MergeInfo = {

@@ -123,2 +161,10 @@ delegate: (type: 'query' | 'mutation' | 'subscription', fieldName: string, args: {

}
export declare type OnTypeConflict = (left: GraphQLNamedType, right: GraphQLNamedType, info?: {
left: {
schema?: GraphQLSchema;
};
right: {
schema?: GraphQLSchema;
};
}) => GraphQLNamedType;
export declare type Operation = 'query' | 'mutation' | 'subscription';

@@ -125,0 +171,0 @@ export declare type Request = {

Object.defineProperty(exports, "__esModule", { value: true });
function isSchemaExecutionConfig(schema) {
return !!schema.schema;
}
exports.isSchemaExecutionConfig = isSchemaExecutionConfig;
function isRemoteSchemaExecutionConfig(schema) {
return (!!schema.dispatcher ||
!!schema.link ||
!!schema.fetcher);
}
exports.isRemoteSchemaExecutionConfig = isRemoteSchemaExecutionConfig;
//# sourceMappingURL=Interfaces.js.map

@@ -60,3 +60,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

return __awaiter(this, void 0, void 0, function () {
var info, _a, args, operation, rawDocument, rawRequest, transforms, processedRequest, errors, _b, executionResult;
var info, _a, args, operation, rawDocument, rawRequest, transforms, processedRequest, errors, _b, originalAsyncIterator;
return __generator(this, function (_c) {

@@ -92,4 +92,20 @@ switch (_c.label) {

if (!(operation === 'query' || operation === 'mutation')) return [3 /*break*/, 2];
if (!options.executor) {
options.executor = function (_a) {
var document = _a.document, context = _a.context, variables = _a.variables;
return graphql_1.execute({
schema: options.schema,
document: document,
rootValue: info.rootValue,
contextValue: context,
variableValues: variables,
});
};
}
_b = transforms_1.applyResultTransforms;
return [4 /*yield*/, graphql_1.execute(options.schema, processedRequest.document, info.rootValue, options.context, processedRequest.variables)];
return [4 /*yield*/, options.executor({
document: processedRequest.document,
context: options.context,
variables: processedRequest.variables
})];
case 1: return [2 /*return*/, _b.apply(void 0, [_c.sent(),

@@ -99,7 +115,23 @@ transforms])];

if (!(operation === 'subscription')) return [3 /*break*/, 4];
return [4 /*yield*/, graphql_1.subscribe(options.schema, processedRequest.document, info.rootValue, options.context, processedRequest.variables)];
if (!options.subscriber) {
options.subscriber = function (_a) {
var document = _a.document, context = _a.context, variables = _a.variables;
return graphql_1.subscribe({
schema: options.schema,
document: document,
rootValue: info.rootValue,
contextValue: context,
variableValues: variables,
});
};
}
return [4 /*yield*/, options.subscriber({
document: processedRequest.document,
context: options.context,
variables: processedRequest.variables,
})];
case 3:
executionResult = (_c.sent());
originalAsyncIterator = (_c.sent());
// "subscribe" to the subscription result and map the result through the transforms
return [2 /*return*/, mapAsyncIterator_1.default(executionResult, function (result) {
return [2 /*return*/, mapAsyncIterator_1.default(originalAsyncIterator, function (result) {
var _a;

@@ -106,0 +138,0 @@ var transformedResult = transforms_1.applyResultTransforms(result, transforms);

3

dist/stitching/index.d.ts

@@ -5,3 +5,4 @@ import makeRemoteExecutableSchema, { createResolver as defaultCreateRemoteResolver } from './makeRemoteExecutableSchema';

import delegateToSchema from './delegateToSchema';
import delegateToRemoteSchema from './delegateToRemoteSchema';
import defaultMergedResolver from './defaultMergedResolver';
export { makeRemoteExecutableSchema, introspectSchema, mergeSchemas, delegateToSchema, defaultMergedResolver, defaultCreateRemoteResolver };
export { makeRemoteExecutableSchema, introspectSchema, mergeSchemas, delegateToSchema, delegateToRemoteSchema, defaultMergedResolver, defaultCreateRemoteResolver };

@@ -11,4 +11,6 @@ Object.defineProperty(exports, "__esModule", { value: true });

exports.delegateToSchema = delegateToSchema_1.default;
var delegateToRemoteSchema_1 = require("./delegateToRemoteSchema");
exports.delegateToRemoteSchema = delegateToRemoteSchema_1.default;
var defaultMergedResolver_1 = require("./defaultMergedResolver");
exports.defaultMergedResolver = defaultMergedResolver_1.default;
//# sourceMappingURL=index.js.map
import { GraphQLSchema } from 'graphql';
import { ApolloLink } from 'apollo-link';
import { Fetcher } from './makeRemoteExecutableSchema';
import { Fetcher } from '../Interfaces';
export default function introspectSchema(fetcher: ApolloLink | Fetcher, linkContext?: {
[key: string]: any;
}): Promise<GraphQLSchema>;

@@ -1,4 +0,4 @@

import { Fetcher } from './makeRemoteExecutableSchema';
import { Fetcher } from '../Interfaces';
import { ApolloLink } from 'apollo-link';
export { execute } from 'apollo-link';
export default function linkToFetcher(link: ApolloLink): Fetcher;
import { ApolloLink } from 'apollo-link';
import { GraphQLFieldResolver, GraphQLSchema, ExecutionResult, GraphQLResolveInfo, DocumentNode, BuildSchemaOptions } from 'graphql';
import { GraphQLFieldResolver, GraphQLSchema, GraphQLResolveInfo, BuildSchemaOptions } from 'graphql';
import { Fetcher } from '../Interfaces';
import { Options as PrintSchemaOptions } from 'graphql/utilities/schemaPrinter';
export declare type ResolverFn = (rootValue?: any, args?: any, context?: any, info?: GraphQLResolveInfo) => AsyncIterator<any>;
export declare type Fetcher = (operation: FetcherOperation) => Promise<ExecutionResult>;
export declare type FetcherOperation = {
query: DocumentNode;
operationName?: string;
variables?: {
[key: string]: any;
};
context?: {
[key: string]: any;
};
};
export default function makeRemoteExecutableSchema({ schema, link, fetcher, createResolver: customCreateResolver, buildSchemaOptions, printSchemaOptions }: {

@@ -17,0 +7,0 @@ schema: GraphQLSchema | string;

import { DocumentNode, GraphQLNamedType, GraphQLSchema } from 'graphql';
import { IResolversParameter } from '../Interfaces';
import { OnTypeConflict, IResolversParameter, SchemaExecutionConfig } from '../Interfaces';
import { SchemaDirectiveVisitor } from '../schemaVisitor';
declare type OnTypeConflict = (left: GraphQLNamedType, right: GraphQLNamedType, info?: {
left: {
schema?: GraphQLSchema;
};
right: {
schema?: GraphQLSchema;
};
}) => GraphQLNamedType;
export default function mergeSchemas({ schemas, onTypeConflict, resolvers, schemaDirectives, inheritResolversFromInterfaces, mergeDirectives, }: {
schemas: Array<string | GraphQLSchema | DocumentNode | Array<GraphQLNamedType>>;
schemas: Array<string | GraphQLSchema | SchemaExecutionConfig | DocumentNode | Array<GraphQLNamedType>>;
onTypeConflict?: OnTypeConflict;

@@ -22,2 +14,1 @@ resolvers?: IResolversParameter;

}): GraphQLSchema;
export {};

@@ -14,5 +14,7 @@ var __assign = (this && this.__assign) || function () {

var graphql_1 = require("graphql");
var Interfaces_1 = require("../Interfaces");
var makeExecutableSchema_1 = require("../makeExecutableSchema");
var schemaRecreation_1 = require("./schemaRecreation");
var delegateToSchema_1 = require("./delegateToSchema");
var delegateToRemoteSchema_1 = require("./delegateToRemoteSchema");
var typeFromAST_1 = require("./typeFromAST");

@@ -36,3 +38,12 @@ var transforms_1 = require("../transforms");

});
schemas.forEach(function (schema) {
schemas.forEach(function (schemaOrSchemaExecutionConfig) {
var schema;
var executionConfig;
if (Interfaces_1.isSchemaExecutionConfig(schemaOrSchemaExecutionConfig)) {
executionConfig = schemaOrSchemaExecutionConfig;
schema = schemaOrSchemaExecutionConfig.schema;
}
else {
schema = schemaOrSchemaExecutionConfig;
}
if (schema instanceof graphql_1.GraphQLSchema) {

@@ -46,2 +57,3 @@ allSchemas.push(schema);

schema: schema,
executionConfig: executionConfig,
type: queryType_1,

@@ -53,2 +65,3 @@ });

schema: schema,
executionConfig: executionConfig,
type: mutationType_1,

@@ -60,2 +73,3 @@ });

schema: schema,
executionConfig: executionConfig,
type: subscriptionType_1,

@@ -80,2 +94,3 @@ });

schema: schema,
executionConfig: executionConfig,
type: type,

@@ -261,3 +276,13 @@ });

}
function createDelegatingResolver(schema, operation, fieldName) {
function createDelegatingResolver(_a) {
var schema = _a.schema, executionConfig = _a.executionConfig, operation = _a.operation, fieldName = _a.fieldName;
if (executionConfig && Interfaces_1.isRemoteSchemaExecutionConfig(executionConfig)) {
return function (root, args, context, info) {
return delegateToRemoteSchema_1.default(__assign({}, executionConfig, { operation: operation,
fieldName: fieldName,
args: args,
context: context,
info: info }));
};
}
return function (root, args, context, info) {

@@ -344,3 +369,3 @@ return info.mergeInfo.delegateToSchema({

candidates.forEach(function (_a) {
var candidateType = _a.type, schema = _a.schema;
var candidateType = _a.type, schema = _a.schema, executionConfig = _a.executionConfig;
var candidateFields = candidateType.getFields();

@@ -351,3 +376,8 @@ fields_2 = __assign({}, fields_2, candidateFields);

resolvers_1[fieldName] = (_a = {},
_a[resolverKey_1] = schema ? createDelegatingResolver(schema, operationName_1, fieldName) : null,
_a[resolverKey_1] = schema ? createDelegatingResolver({
schema: schema,
executionConfig: executionConfig,
operation: operationName_1,
fieldName: fieldName,
}) : null,
_a);

@@ -354,0 +384,0 @@ });

import { GraphQLSchema, GraphQLObjectType } from 'graphql';
import { IResolvers, Operation } from '../Interfaces';
import { IResolvers, Operation, SchemaExecutionConfig } from '../Interfaces';
import { Transform } from '../transforms/index';

@@ -12,3 +12,3 @@ export declare type Mapping = {

};
export declare function generateProxyingResolvers(targetSchema: GraphQLSchema, transforms: Array<Transform>, mapping: Mapping): IResolvers;
export declare function generateProxyingResolvers(targetSchema: GraphQLSchema | SchemaExecutionConfig, transforms: Array<Transform>, mapping: Mapping): IResolvers;
export declare function generateSimpleMapping(targetSchema: GraphQLSchema): Mapping;

@@ -15,0 +15,0 @@ export declare function generateMappingFromObjectType(type: GraphQLObjectType, operation: Operation): {

@@ -0,2 +1,14 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
var Interfaces_1 = require("../Interfaces");
var delegateToSchema_1 = require("./delegateToSchema");

@@ -50,2 +62,8 @@ function generateProxyingResolvers(targetSchema, transforms, mapping) {

function createProxyingResolver(schema, operation, fieldName, transforms) {
if (Interfaces_1.isRemoteSchemaExecutionConfig(schema)) {
return function (parent, args, context, info) { return delegateToSchema_1.default(__assign({}, schema, { operation: operation,
fieldName: fieldName, args: {}, context: context,
info: info,
transforms: transforms })); };
}
return function (parent, args, context, info) { return delegateToSchema_1.default({

@@ -52,0 +70,0 @@ schema: schema,

import { Transform } from './transforms';
export { Transform };
export { default as filterSchema } from './filterSchema';
export { default as transformSchema } from './transformSchema';

@@ -20,1 +21,2 @@ export { default as AddArgumentsAsVariables } from './AddArgumentsAsVariables';

export { default as WrapQuery } from './WrapQuery';
export { default as TransformQuery } from './TransformQuery';
Object.defineProperty(exports, "__esModule", { value: true });
var filterSchema_1 = require("./filterSchema");
exports.filterSchema = filterSchema_1.default;
var transformSchema_1 = require("./transformSchema");

@@ -36,2 +38,4 @@ exports.transformSchema = transformSchema_1.default;

exports.WrapQuery = WrapQuery_1.default;
var TransformQuery_1 = require("./TransformQuery");
exports.TransformQuery = TransformQuery_1.default;
//# sourceMappingURL=index.js.map
import { GraphQLSchema } from 'graphql';
import { Transform } from '../transforms/transforms';
export default function transformSchema(targetSchema: GraphQLSchema, transforms: Array<Transform>): GraphQLSchema & {
import { SchemaExecutionConfig } from '../Interfaces';
export default function transformSchema(schemaOrSchemaExecutionConfig: GraphQLSchema | SchemaExecutionConfig, transforms: Array<Transform>): GraphQLSchema & {
transforms: Array<Transform>;
};

@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });

var resolvers_1 = require("../stitching/resolvers");
function transformSchema(targetSchema, transforms) {
var Interfaces_1 = require("../Interfaces");
function transformSchema(schemaOrSchemaExecutionConfig, transforms) {
var targetSchema = Interfaces_1.isSchemaExecutionConfig(schemaOrSchemaExecutionConfig) ?
schemaOrSchemaExecutionConfig.schema : schemaOrSchemaExecutionConfig;
var schema = visitSchema_1.visitSchema(targetSchema, {}, true);
var mapping = resolvers_1.generateSimpleMapping(targetSchema);
var resolvers = resolvers_1.generateProxyingResolvers(targetSchema, transforms, mapping);
var resolvers = resolvers_1.generateProxyingResolvers(schemaOrSchemaExecutionConfig, transforms, mapping);
schema = makeExecutableSchema_1.addResolveFunctionsToSchema({

@@ -12,0 +15,0 @@ schema: schema,

{
"name": "graphql-tools-fork",
"version": "6.1.6",
"version": "6.2.0",
"description": "Forked graphql-tools, still more useful tools to create and manipulate GraphQL schemas.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -30,4 +30,2 @@ # graphql-tools-fork: keep on stitching

[See and edit the live example on Launchpad.](https://launchpad.graphql.com/1jzxrj179)
When using `graphql-tools`, you describe the schema as a GraphQL type language string:

@@ -34,0 +32,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc