Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@graphql-tools/delegate

Package Overview
Dependencies
Maintainers
3
Versions
1823
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/delegate - npm Package Compare versions

Comparing version 6.0.11-alpha-abf0746.0 to 6.0.11-alpha-d958e71.0

98

index.cjs.js

@@ -730,6 +730,24 @@ 'use strict';

if (errors.length) {
if (errors.length > 1) {
return new AggregateError(errors.map(error => error.graphQLError));
if (errors.some(error => !error.path || error.path.length < 2)) {
if (errors.length > 1) {
const combinedError = new AggregateError(errors);
return combinedError;
}
const error = errors[0];
return error.originalError || utils.relocatedError(error, null);
}
return errors[0].graphQLError;
else if (errors.some(error => typeof error.path[1] === 'string')) {
const childErrors = utils.getErrorsByPathSegment(errors);
const result = {};
Object.keys(childErrors).forEach(pathSegment => {
result[pathSegment] = handleNull(childErrors[pathSegment]);
});
return result;
}
const childErrors = utils.getErrorsByPathSegment(errors);
const result = [];
Object.keys(childErrors).forEach(pathSegment => {
result.push(handleNull(childErrors[pathSegment]));
});
return result;
}

@@ -750,3 +768,3 @@ return null;

}
utils.setErrors(object, errors.map(error => utils.sliceRelativeError(error)));
utils.setErrors(object, errors.map(error => utils.relocatedError(error, error.path != null ? error.path.slice(1) : undefined)));
setObjectSubschema(object, subschema);

@@ -769,10 +787,9 @@ newParent = object;

result[utils.ERROR_SYMBOL] = parent[utils.ERROR_SYMBOL].map((error) => {
const path = error.relativePath.slice();
const pathSegment = path.shift();
const expandedPathSegment = pathSegment.split(delimeter);
return {
relativePath: expandedPathSegment.concat(path),
// setting path to null will cause issues for errors that bubble up from non nullable fields
graphQLError: utils.relocatedError(error.graphQLError, null),
};
if (error.path != null) {
const path = error.path.slice();
const pathSegment = path.shift();
const expandedPathSegment = pathSegment.split(delimeter);
return utils.relocatedError(error, expandedPathSegment.concat(path));
}
return error;
});

@@ -826,34 +843,35 @@ result[OBJECT_SUBSCHEMA_SYMBOL] = parent[OBJECT_SUBSCHEMA_SYMBOL];

if (uniqueSubschema != null) {
if (proxiableSubschemas.includes(uniqueSubschema)) {
const existingSubschema = delegationMap.get(uniqueSubschema);
if (existingSubschema != null) {
existingSubschema.push(selection);
}
else {
delegationMap.set(uniqueSubschema, [selection]);
}
}
else {
if (!proxiableSubschemas.includes(uniqueSubschema)) {
unproxiableSelections.push(selection);
return;
}
}
else {
// 2b. use nonUniqueFields to assign to a possible subschema,
// preferring one of the subschemas already targets of delegation
let nonUniqueSubschemas = nonUniqueFields[selection.name.value];
nonUniqueSubschemas = nonUniqueSubschemas.filter(s => proxiableSubschemas.includes(s));
if (nonUniqueSubschemas != null) {
const subschemas = Array.from(delegationMap.keys());
const existingSubschema = nonUniqueSubschemas.find(s => subschemas.includes(s));
if (existingSubschema != null) {
delegationMap.get(existingSubschema).push(selection);
}
else {
delegationMap.set(nonUniqueSubschemas[0], [selection]);
}
const existingSubschema = delegationMap.get(uniqueSubschema);
if (existingSubschema != null) {
existingSubschema.push(selection);
}
else {
unproxiableSelections.push(selection);
delegationMap.set(uniqueSubschema, [selection]);
}
return;
}
// 2b. use nonUniqueFields to assign to a possible subschema,
// preferring one of the subschemas already targets of delegation
let nonUniqueSubschemas = nonUniqueFields[selection.name.value];
if (nonUniqueSubschemas == null) {
unproxiableSelections.push(selection);
return;
}
nonUniqueSubschemas = nonUniqueSubschemas.filter(s => proxiableSubschemas.includes(s));
if (nonUniqueSubschemas == null) {
unproxiableSelections.push(selection);
return;
}
const subschemas = Array.from(delegationMap.keys());
const existingSubschema = nonUniqueSubschemas.find(s => subschemas.includes(s));
if (existingSubschema != null) {
delegationMap.get(existingSubschema).push(selection);
}
else {
delegationMap.set(nonUniqueSubschemas[0], [selection]);
}
});

@@ -898,3 +916,3 @@ return {

const stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a.stitchingInfo;
utils.setErrors(object, errors.map(error => utils.sliceRelativeError(error)));
utils.setErrors(object, errors.map(error => utils.slicedError(error)));
setObjectSubschema(object, subschema);

@@ -996,3 +1014,3 @@ if (skipTypeMerging || !stitchingInfo) {

function checkResultAndHandleErrors(result, context, info, responseKey = utils.getResponseKeyFromInfo(info), subschema, returnType = info.returnType, skipTypeMerging) {
const errors = result.errors != null ? result.errors.map(error => utils.toRelativeError(error, info)) : [];
const errors = result.errors != null ? result.errors : [];
const data = result.data != null ? result.data[responseKey] : undefined;

@@ -999,0 +1017,0 @@ return handleResult(data, errors, subschema, context, info, returnType, skipTypeMerging);

import { Kind, typeFromAST, visit, visitWithTypeInfo, getNamedType, isAbstractType, TypeInfo, isObjectType, isInterfaceType, TypeNameMetaFieldDef, getNullableType, isLeafType, isCompositeType, isListType, isSchema, getOperationAST, execute, subscribe, validate, defaultFieldResolver, parse } from 'graphql';
import { applySchemaTransforms, serializeInputValue, updateArgument, implementsAbstractType, ERROR_SYMBOL, relocatedError, mergeDeep, getErrors, setErrors, sliceRelativeError, collectFields, getErrorsByPathSegment, getResponseKeyFromInfo, toRelativeError, mapAsyncIterator, concatInlineFragments } from '@graphql-tools/utils';
import { applySchemaTransforms, serializeInputValue, updateArgument, implementsAbstractType, relocatedError, getErrorsByPathSegment, ERROR_SYMBOL, mergeDeep, getErrors, setErrors, slicedError, collectFields, getResponseKeyFromInfo, mapAsyncIterator, concatInlineFragments } from '@graphql-tools/utils';
import AggregateError from 'aggregate-error';

@@ -724,6 +724,24 @@

if (errors.length) {
if (errors.length > 1) {
return new AggregateError(errors.map(error => error.graphQLError));
if (errors.some(error => !error.path || error.path.length < 2)) {
if (errors.length > 1) {
const combinedError = new AggregateError(errors);
return combinedError;
}
const error = errors[0];
return error.originalError || relocatedError(error, null);
}
return errors[0].graphQLError;
else if (errors.some(error => typeof error.path[1] === 'string')) {
const childErrors = getErrorsByPathSegment(errors);
const result = {};
Object.keys(childErrors).forEach(pathSegment => {
result[pathSegment] = handleNull(childErrors[pathSegment]);
});
return result;
}
const childErrors = getErrorsByPathSegment(errors);
const result = [];
Object.keys(childErrors).forEach(pathSegment => {
result.push(handleNull(childErrors[pathSegment]));
});
return result;
}

@@ -744,3 +762,3 @@ return null;

}
setErrors(object, errors.map(error => sliceRelativeError(error)));
setErrors(object, errors.map(error => relocatedError(error, error.path != null ? error.path.slice(1) : undefined)));
setObjectSubschema(object, subschema);

@@ -763,10 +781,9 @@ newParent = object;

result[ERROR_SYMBOL] = parent[ERROR_SYMBOL].map((error) => {
const path = error.relativePath.slice();
const pathSegment = path.shift();
const expandedPathSegment = pathSegment.split(delimeter);
return {
relativePath: expandedPathSegment.concat(path),
// setting path to null will cause issues for errors that bubble up from non nullable fields
graphQLError: relocatedError(error.graphQLError, null),
};
if (error.path != null) {
const path = error.path.slice();
const pathSegment = path.shift();
const expandedPathSegment = pathSegment.split(delimeter);
return relocatedError(error, expandedPathSegment.concat(path));
}
return error;
});

@@ -820,34 +837,35 @@ result[OBJECT_SUBSCHEMA_SYMBOL] = parent[OBJECT_SUBSCHEMA_SYMBOL];

if (uniqueSubschema != null) {
if (proxiableSubschemas.includes(uniqueSubschema)) {
const existingSubschema = delegationMap.get(uniqueSubschema);
if (existingSubschema != null) {
existingSubschema.push(selection);
}
else {
delegationMap.set(uniqueSubschema, [selection]);
}
}
else {
if (!proxiableSubschemas.includes(uniqueSubschema)) {
unproxiableSelections.push(selection);
return;
}
}
else {
// 2b. use nonUniqueFields to assign to a possible subschema,
// preferring one of the subschemas already targets of delegation
let nonUniqueSubschemas = nonUniqueFields[selection.name.value];
nonUniqueSubschemas = nonUniqueSubschemas.filter(s => proxiableSubschemas.includes(s));
if (nonUniqueSubschemas != null) {
const subschemas = Array.from(delegationMap.keys());
const existingSubschema = nonUniqueSubschemas.find(s => subschemas.includes(s));
if (existingSubschema != null) {
delegationMap.get(existingSubschema).push(selection);
}
else {
delegationMap.set(nonUniqueSubschemas[0], [selection]);
}
const existingSubschema = delegationMap.get(uniqueSubschema);
if (existingSubschema != null) {
existingSubschema.push(selection);
}
else {
unproxiableSelections.push(selection);
delegationMap.set(uniqueSubschema, [selection]);
}
return;
}
// 2b. use nonUniqueFields to assign to a possible subschema,
// preferring one of the subschemas already targets of delegation
let nonUniqueSubschemas = nonUniqueFields[selection.name.value];
if (nonUniqueSubschemas == null) {
unproxiableSelections.push(selection);
return;
}
nonUniqueSubschemas = nonUniqueSubschemas.filter(s => proxiableSubschemas.includes(s));
if (nonUniqueSubschemas == null) {
unproxiableSelections.push(selection);
return;
}
const subschemas = Array.from(delegationMap.keys());
const existingSubschema = nonUniqueSubschemas.find(s => subschemas.includes(s));
if (existingSubschema != null) {
delegationMap.get(existingSubschema).push(selection);
}
else {
delegationMap.set(nonUniqueSubschemas[0], [selection]);
}
});

@@ -892,3 +910,3 @@ return {

const stitchingInfo = (_a = info === null || info === void 0 ? void 0 : info.schema.extensions) === null || _a === void 0 ? void 0 : _a.stitchingInfo;
setErrors(object, errors.map(error => sliceRelativeError(error)));
setErrors(object, errors.map(error => slicedError(error)));
setObjectSubschema(object, subschema);

@@ -990,3 +1008,3 @@ if (skipTypeMerging || !stitchingInfo) {

function checkResultAndHandleErrors(result, context, info, responseKey = getResponseKeyFromInfo(info), subschema, returnType = info.returnType, skipTypeMerging) {
const errors = result.errors != null ? result.errors.map(error => toRelativeError(error, info)) : [];
const errors = result.errors != null ? result.errors : [];
const data = result.data != null ? result.data[responseKey] : undefined;

@@ -993,0 +1011,0 @@ return handleResult(data, errors, subschema, context, info, returnType, skipTypeMerging);

{
"name": "@graphql-tools/delegate",
"version": "6.0.11-alpha-abf0746.0",
"version": "6.0.11-alpha-d958e71.0",
"description": "A set of utils for faster development of GraphQL tools",

@@ -10,4 +10,4 @@ "sideEffects": false,

"dependencies": {
"@graphql-tools/schema": "6.0.11-alpha-abf0746.0",
"@graphql-tools/utils": "6.0.11-alpha-abf0746.0",
"@graphql-tools/schema": "6.0.11-alpha-d958e71.0",
"@graphql-tools/utils": "6.0.11-alpha-d958e71.0",
"aggregate-error": "3.0.1",

@@ -14,0 +14,0 @@ "tslib": "~2.0.0"

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

import { GraphQLList, GraphQLSchema, GraphQLResolveInfo } from 'graphql';
import { RelativeGraphQLError } from '@graphql-tools/utils';
import { GraphQLList, GraphQLSchema, GraphQLError, GraphQLResolveInfo } from 'graphql';
import { SubschemaConfig } from '../types';
export declare function handleList(type: GraphQLList<any>, list: Array<any>, errors: Array<RelativeGraphQLError>, subschema: GraphQLSchema | SubschemaConfig, context: Record<string, any>, info: GraphQLResolveInfo, skipTypeMerging?: boolean): any[];
export declare function handleList(type: GraphQLList<any>, list: Array<any>, errors: ReadonlyArray<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig, context: Record<string, any>, info: GraphQLResolveInfo, skipTypeMerging?: boolean): any[];

@@ -1,3 +0,2 @@

import AggregateError from 'aggregate-error';
import { RelativeGraphQLError } from '@graphql-tools/utils';
export declare function handleNull(errors: Array<RelativeGraphQLError>): import("graphql").GraphQLError | AggregateError;
import { GraphQLError } from 'graphql';
export declare function handleNull(errors: ReadonlyArray<GraphQLError>): {};

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

import { GraphQLCompositeType, GraphQLSchema, GraphQLResolveInfo } from 'graphql';
import { RelativeGraphQLError } from '@graphql-tools/utils';
import { GraphQLCompositeType, GraphQLError, GraphQLSchema, GraphQLResolveInfo } from 'graphql';
import { SubschemaConfig } from '../types';
export declare function handleObject(type: GraphQLCompositeType, object: any, errors: Array<RelativeGraphQLError>, subschema: GraphQLSchema | SubschemaConfig, context: Record<string, any>, info: GraphQLResolveInfo, skipTypeMerging?: boolean): any;
export declare function handleObject(type: GraphQLCompositeType, object: any, errors: ReadonlyArray<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig, context: Record<string, any>, info: GraphQLResolveInfo, skipTypeMerging?: boolean): any;

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

import { GraphQLResolveInfo, GraphQLSchema } from 'graphql';
import { RelativeGraphQLError } from '@graphql-tools/utils';
import { GraphQLResolveInfo, GraphQLError, GraphQLSchema } from 'graphql';
import { SubschemaConfig } from '../types';
export declare function handleResult(result: any, errors: Array<RelativeGraphQLError>, subschema: GraphQLSchema | SubschemaConfig, context: Record<string, any>, info: GraphQLResolveInfo, returnType?: import("graphql").GraphQLOutputType, skipTypeMerging?: boolean): any;
export declare function handleResult(result: any, errors: ReadonlyArray<GraphQLError>, subschema: GraphQLSchema | SubschemaConfig, context: Record<string, any>, info: GraphQLResolveInfo, returnType?: import("graphql").GraphQLOutputType, skipTypeMerging?: boolean): any;

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