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

@graphql-tools/executor

Package Overview
Dependencies
Maintainers
3
Versions
343
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@graphql-tools/executor - npm Package Compare versions

Comparing version 2.0.0-alpha-20240804115623-ba8ea361d8cc77c657068ef6648d977439b63ab3 to 2.0.0-alpha-20240805144842-131e76d507ce82e59a400bf90758e7af71493abf

18

cjs/execution/collectFields.js

@@ -17,3 +17,3 @@ "use strict";

*/
function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, errorWithIncrementalSubscription) {
function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, errorOnSubscriptionWithIncrementalDelivery) {
const groupedFieldSet = new AccumulatorMap_js_1.AccumulatorMap();

@@ -26,3 +26,3 @@ const newDeferUsages = [];

runtimeType,
errorWithIncrementalSubscription,
errorOnSubscriptionWithIncrementalDelivery,
visitedFragmentNames: new Set(),

@@ -44,3 +44,3 @@ };

*/
function collectSubfields(schema, fragments, variableValues, errorWithIncrementalSubscription, returnType, fieldGroup) {
function collectSubfields(schema, fragments, variableValues, errorOnSubscriptionWithIncrementalDelivery, returnType, fieldGroup) {
const context = {

@@ -51,3 +51,3 @@ schema,

runtimeType: returnType,
errorWithIncrementalSubscription,
errorOnSubscriptionWithIncrementalDelivery,
visitedFragmentNames: new Set(),

@@ -70,3 +70,3 @@ };

function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages, deferUsage) {
const { schema, fragments, variableValues, runtimeType, errorWithIncrementalSubscription, visitedFragmentNames, } = context;
const { schema, fragments, variableValues, runtimeType, errorOnSubscriptionWithIncrementalDelivery, visitedFragmentNames, } = context;
for (const selection of selectionSet.selections) {

@@ -89,3 +89,3 @@ switch (selection.kind) {

}
const newDeferUsage = getDeferUsage(errorWithIncrementalSubscription, variableValues, selection, deferUsage);
const newDeferUsage = getDeferUsage(errorOnSubscriptionWithIncrementalDelivery, variableValues, selection, deferUsage);
if (!newDeferUsage) {

@@ -102,3 +102,3 @@ collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, deferUsage);

const fragName = selection.name.value;
const newDeferUsage = getDeferUsage(errorWithIncrementalSubscription, variableValues, selection, deferUsage);
const newDeferUsage = getDeferUsage(errorOnSubscriptionWithIncrementalDelivery, variableValues, selection, deferUsage);
if (!newDeferUsage &&

@@ -130,3 +130,3 @@ (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection))) {

*/
function getDeferUsage(errorWithIncrementalSubscription, variableValues, node, parentDeferUsage) {
function getDeferUsage(errorOnSubscriptionWithIncrementalDelivery, variableValues, node, parentDeferUsage) {
const defer = (0, graphql_1.getDirectiveValues)(utils_1.GraphQLDeferDirective, node, variableValues);

@@ -139,3 +139,3 @@ if (!defer) {

}
(0, invariant_js_1.invariant)(!errorWithIncrementalSubscription, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.');
(0, invariant_js_1.invariant)(!errorOnSubscriptionWithIncrementalDelivery, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.');
return {

@@ -142,0 +142,0 @@ label: typeof defer['label'] === 'string' ? defer['label'] : undefined,

@@ -43,6 +43,10 @@ "use strict";

const newPending = this._incrementalGraph.getNewPending(incrementalDataRecords);
const pending = this._pendingSourcesToResults(newPending);
const initialResult = errors === undefined
? { data, pending, hasNext: true }
: { errors, data, pending, hasNext: true };
const initialResult = this._context
.useIncrementalNotifications
? errors === undefined
? { data, pending: this._pendingSourcesToResults(newPending), hasNext: true }
: { errors, data, pending: this._pendingSourcesToResults(newPending), hasNext: true }
: errors === undefined
? { data, hasNext: true }
: { errors, data, hasNext: true };
return {

@@ -162,3 +166,2 @@ initialResult,

.deferredFragmentRecords) {
const id = deferredFragmentRecord.id;
if (!this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)) {

@@ -168,25 +171,22 @@ // This can occur if multiple deferred grouped field sets error for a fragment.

}
(0, invariant_js_1.invariant)(id !== undefined);
if (this._context.sendIncrementalErrorsAsNull) {
if (this._context.useIncrementalNotifications) {
const id = deferredFragmentRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
context.completed.push({
id,
errors: completedExecutionGroup.errors,
});
}
else {
const incrementalEntry = {
id,
errors: completedExecutionGroup.errors,
data: null,
errors: completedExecutionGroup.errors,
};
if (this._context.sendPathAndLabelOnIncremental) {
const { path, label } = deferredFragmentRecord;
incrementalEntry.path = (0, utils_1.pathToArray)(path);
if (label !== undefined) {
incrementalEntry.label = label;
}
const { path, label } = deferredFragmentRecord;
incrementalEntry.path = (0, utils_1.pathToArray)(path);
if (label !== undefined) {
incrementalEntry.label = label;
}
context.incremental.push(incrementalEntry);
context.completed.push({ id });
}
else {
context.completed.push({
id,
errors: completedExecutionGroup.errors,
});
}
}

@@ -202,14 +202,26 @@ return;

}
const id = deferredFragmentRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
const incremental = context.incremental;
const { newPending, successfulExecutionGroups } = completion;
context.pending.push(...this._pendingSourcesToResults(newPending));
for (const successfulExecutionGroup of successfulExecutionGroups) {
const { bestId, subPath } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup);
const incrementalEntry = {
...successfulExecutionGroup.result,
id: bestId,
};
if (this._context.sendPathAndLabelOnIncremental) {
const successfulExecutionGroups = completion.successfulExecutionGroups;
if (this._context.useIncrementalNotifications) {
const id = deferredFragmentRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
context.pending.push(...this._pendingSourcesToResults(completion.newPending));
for (const successfulExecutionGroup of successfulExecutionGroups) {
const { bestId, subPath } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup);
const incrementalEntry = {
...successfulExecutionGroup.result,
id: bestId,
};
if (subPath !== undefined) {
incrementalEntry.subPath = subPath;
}
incremental.push(incrementalEntry);
}
context.completed.push({ id });
}
else {
for (const successfulExecutionGroup of successfulExecutionGroups) {
const incrementalEntry = {
...successfulExecutionGroup.result,
};
const { path, label } = deferredFragmentRecord;

@@ -220,9 +232,5 @@ incrementalEntry.path = (0, utils_1.pathToArray)(path);

}
incremental.push(incrementalEntry);
}
if (subPath !== undefined) {
incrementalEntry.subPath = subPath;
}
incremental.push(incrementalEntry);
}
context.completed.push({ id });
}

@@ -232,27 +240,23 @@ }

const streamRecord = streamItemsResult.streamRecord;
const id = streamRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
if (streamItemsResult.errors !== undefined) {
if (this._context.sendIncrementalErrorsAsNull) {
if (this._context.useIncrementalNotifications) {
const id = streamRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
context.completed.push({
id,
errors: streamItemsResult.errors,
});
}
else {
const incrementalEntry = {
errors: streamItemsResult.errors,
items: null,
id,
errors: streamItemsResult.errors,
};
if (this._context.sendPathAndLabelOnIncremental) {
const { path, label, index } = streamRecord;
incrementalEntry.path = (0, utils_1.pathToArray)((0, utils_1.addPath)(path, index, undefined));
if (label !== undefined) {
incrementalEntry.label = label;
}
const { path, label, index } = streamRecord;
incrementalEntry.path = (0, utils_1.pathToArray)((0, utils_1.addPath)(path, index, undefined));
if (label !== undefined) {
incrementalEntry.label = label;
}
context.incremental.push(incrementalEntry);
context.completed.push({ id });
}
else {
context.completed.push({
id,
errors: streamItemsResult.errors,
});
}
this._incrementalGraph.removeStream(streamRecord);

@@ -269,3 +273,7 @@ if ((0, types_js_1.isCancellableStreamRecord)(streamRecord)) {

else if (streamItemsResult.result === undefined) {
context.completed.push({ id });
if (this._context.useIncrementalNotifications) {
const id = streamRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
context.completed.push({ id });
}
this._incrementalGraph.removeStream(streamRecord);

@@ -280,6 +288,10 @@ if ((0, types_js_1.isCancellableStreamRecord)(streamRecord)) {

const incrementalEntry = {
id,
...bareResult,
};
if (this._context.sendPathAndLabelOnIncremental) {
if (this._context.useIncrementalNotifications) {
const id = streamRecord.id;
(0, invariant_js_1.invariant)(id !== undefined);
incrementalEntry.id = id;
}
else {
const { path, label, index } = streamRecord;

@@ -296,3 +308,5 @@ incrementalEntry.path = (0, utils_1.pathToArray)((0, utils_1.addPath)(path, index, undefined));

const newPending = this._incrementalGraph.getNewPending(incrementalDataRecords);
context.pending.push(...this._pendingSourcesToResults(newPending));
if (this._context.useIncrementalNotifications) {
context.pending.push(...this._pendingSourcesToResults(newPending));
}
}

@@ -299,0 +313,0 @@ }

@@ -14,3 +14,3 @@ import { getDirectiveValues, GraphQLIncludeDirective, GraphQLSkipDirective, isAbstractType, Kind, typeFromAST, } from 'graphql';

*/
export function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, errorWithIncrementalSubscription) {
export function collectFields(schema, fragments, variableValues, runtimeType, selectionSet, errorOnSubscriptionWithIncrementalDelivery) {
const groupedFieldSet = new AccumulatorMap();

@@ -23,3 +23,3 @@ const newDeferUsages = [];

runtimeType,
errorWithIncrementalSubscription,
errorOnSubscriptionWithIncrementalDelivery,
visitedFragmentNames: new Set(),

@@ -40,3 +40,3 @@ };

*/
export function collectSubfields(schema, fragments, variableValues, errorWithIncrementalSubscription, returnType, fieldGroup) {
export function collectSubfields(schema, fragments, variableValues, errorOnSubscriptionWithIncrementalDelivery, returnType, fieldGroup) {
const context = {

@@ -47,3 +47,3 @@ schema,

runtimeType: returnType,
errorWithIncrementalSubscription,
errorOnSubscriptionWithIncrementalDelivery,
visitedFragmentNames: new Set(),

@@ -65,3 +65,3 @@ };

function collectFieldsImpl(context, selectionSet, groupedFieldSet, newDeferUsages, deferUsage) {
const { schema, fragments, variableValues, runtimeType, errorWithIncrementalSubscription, visitedFragmentNames, } = context;
const { schema, fragments, variableValues, runtimeType, errorOnSubscriptionWithIncrementalDelivery, visitedFragmentNames, } = context;
for (const selection of selectionSet.selections) {

@@ -84,3 +84,3 @@ switch (selection.kind) {

}
const newDeferUsage = getDeferUsage(errorWithIncrementalSubscription, variableValues, selection, deferUsage);
const newDeferUsage = getDeferUsage(errorOnSubscriptionWithIncrementalDelivery, variableValues, selection, deferUsage);
if (!newDeferUsage) {

@@ -97,3 +97,3 @@ collectFieldsImpl(context, selection.selectionSet, groupedFieldSet, newDeferUsages, deferUsage);

const fragName = selection.name.value;
const newDeferUsage = getDeferUsage(errorWithIncrementalSubscription, variableValues, selection, deferUsage);
const newDeferUsage = getDeferUsage(errorOnSubscriptionWithIncrementalDelivery, variableValues, selection, deferUsage);
if (!newDeferUsage &&

@@ -125,3 +125,3 @@ (visitedFragmentNames.has(fragName) || !shouldIncludeNode(variableValues, selection))) {

*/
function getDeferUsage(errorWithIncrementalSubscription, variableValues, node, parentDeferUsage) {
function getDeferUsage(errorOnSubscriptionWithIncrementalDelivery, variableValues, node, parentDeferUsage) {
const defer = getDirectiveValues(GraphQLDeferDirective, node, variableValues);

@@ -134,3 +134,3 @@ if (!defer) {

}
invariant(!errorWithIncrementalSubscription, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.');
invariant(!errorOnSubscriptionWithIncrementalDelivery, '`@defer` directive not supported on subscription operations. Disable `@defer` by setting the `if` argument to `false`.');
return {

@@ -137,0 +137,0 @@ label: typeof defer['label'] === 'string' ? defer['label'] : undefined,

@@ -19,3 +19,3 @@ import { assertValidSchema, getDirectiveValues, GraphQLError, isAbstractType, isLeafType, isListType, isNonNullType, isObjectType, Kind, locatedError, SchemaMetaFieldDef, TypeMetaFieldDef, TypeNameMetaFieldDef, versionInfo, } from 'graphql';

*/
const collectSubfields = memoize3((exeContext, returnType, fieldGroup) => _collectSubfields(exeContext.schema, exeContext.fragments, exeContext.variableValues, exeContext.errorWithIncrementalSubscription, returnType, fieldGroup));
const collectSubfields = memoize3((exeContext, returnType, fieldGroup) => _collectSubfields(exeContext.schema, exeContext.fragments, exeContext.variableValues, exeContext.errorOnSubscriptionWithIncrementalDelivery, returnType, fieldGroup));
/**

@@ -153,3 +153,3 @@ * Implements the "Executing requests" section of the GraphQL specification,

export function buildExecutionContext(args) {
const { schema, document, rootValue, contextValue, variableValues: rawVariableValues, operationName, fieldResolver, typeResolver, subscribeFieldResolver, enableEarlyExecution, deduplicateDefers, sendIncrementalErrorsAsNull, sendPathAndLabelOnIncremental, errorWithIncrementalSubscription, signal, } = args;
const { schema, document, rootValue, contextValue, variableValues: rawVariableValues, operationName, fieldResolver, typeResolver, subscribeFieldResolver, enableEarlyExecution, incrementalPreset, deferWithoutDuplication, useIncrementalNotifications, errorOnSubscriptionWithIncrementalDelivery, signal, } = args;
// If the schema used for execution is invalid, throw an error.

@@ -193,2 +193,3 @@ assertValidSchema(schema);

}
const latestPreset = incrementalPreset !== 'v17.0.0-alpha.2';
return {

@@ -205,6 +206,8 @@ schema,

enableEarlyExecution: enableEarlyExecution !== false,
deduplicateDefers: deduplicateDefers !== false,
sendIncrementalErrorsAsNull: sendIncrementalErrorsAsNull === true,
sendPathAndLabelOnIncremental: sendPathAndLabelOnIncremental === true,
errorWithIncrementalSubscription: operation.operation === 'subscription' && errorWithIncrementalSubscription !== false,
deferWithoutDuplication: deferWithoutDuplication != null ? deferWithoutDuplication : latestPreset,
useIncrementalNotifications: useIncrementalNotifications != null ? useIncrementalNotifications : latestPreset,
errorOnSubscriptionWithIncrementalDelivery: operation.operation === 'subscription' &&
(errorOnSubscriptionWithIncrementalDelivery != null
? errorOnSubscriptionWithIncrementalDelivery
: latestPreset),
signal,

@@ -231,3 +234,3 @@ errors: undefined,

try {
const { operation, schema, fragments, variableValues, rootValue, deduplicateDefers, errorWithIncrementalSubscription, } = exeContext;
const { operation, schema, fragments, variableValues, rootValue, deferWithoutDuplication, errorOnSubscriptionWithIncrementalDelivery, } = exeContext;
const rootType = getDefinedRootType(schema, operation.operation, [operation]);

@@ -239,3 +242,3 @@ if (rootType == null) {

}
const collectedFields = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet, errorWithIncrementalSubscription);
const collectedFields = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet, errorOnSubscriptionWithIncrementalDelivery);
let groupedFieldSet = collectedFields.groupedFieldSet;

@@ -248,3 +251,3 @@ const newDeferUsages = collectedFields.newDeferUsages;

else {
const executionPlan = deduplicateDefers
const executionPlan = deferWithoutDuplication
? buildExecutionPlan(groupedFieldSet)

@@ -562,3 +565,3 @@ : buildBranchingExecutionPlan(groupedFieldSet);

invariant(stream['initialCount'] >= 0, 'initialCount must be a positive integer');
invariant(!exeContext.errorWithIncrementalSubscription, '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.');
invariant(!exeContext.errorOnSubscriptionWithIncrementalDelivery, '`@stream` directive not supported on subscription operations. Disable `@stream` by setting the `if` argument to `false`.');
const streamedFieldGroup = fieldGroup.map(fieldDetails => ({

@@ -872,3 +875,3 @@ node: fieldDetails.node,

}
const subExecutionPlan = buildSubExecutionPlan(groupedFieldSet, incrementalContext?.deferUsageSet, exeContext.deduplicateDefers);
const subExecutionPlan = buildSubExecutionPlan(groupedFieldSet, incrementalContext?.deferUsageSet, exeContext.deferWithoutDuplication);
groupedFieldSet = subExecutionPlan.groupedFieldSet;

@@ -885,3 +888,3 @@ const newGroupedFieldSets = subExecutionPlan.newGroupedFieldSets;

}
function buildSubExecutionPlan(originalGroupedFieldSet, deferUsageSet, deduplicateDefers) {
function buildSubExecutionPlan(originalGroupedFieldSet, deferUsageSet, deferWithoutDuplication) {
let executionPlan = originalGroupedFieldSet

@@ -892,3 +895,3 @@ ._executionPlan;

}
executionPlan = deduplicateDefers
executionPlan = deferWithoutDuplication
? buildExecutionPlan(originalGroupedFieldSet, deferUsageSet)

@@ -1061,3 +1064,3 @@ : buildBranchingExecutionPlan(originalGroupedFieldSet, deferUsageSet);

function executeSubscription(exeContext) {
const { schema, fragments, operation, variableValues, rootValue, errorWithIncrementalSubscription, } = exeContext;
const { schema, fragments, operation, variableValues, rootValue, errorOnSubscriptionWithIncrementalDelivery, } = exeContext;
const rootType = schema.getSubscriptionType();

@@ -1069,3 +1072,3 @@ if (rootType == null) {

}
const { groupedFieldSet } = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet, errorWithIncrementalSubscription);
const { groupedFieldSet } = collectFields(schema, fragments, variableValues, rootType, operation.selectionSet, errorOnSubscriptionWithIncrementalDelivery);
const firstRootField = [...groupedFieldSet.entries()][0];

@@ -1072,0 +1075,0 @@ const [responseName, fieldGroup] = firstRootField;

@@ -39,6 +39,10 @@ import { addPath, pathToArray } from '@graphql-tools/utils';

const newPending = this._incrementalGraph.getNewPending(incrementalDataRecords);
const pending = this._pendingSourcesToResults(newPending);
const initialResult = errors === undefined
? { data, pending, hasNext: true }
: { errors, data, pending, hasNext: true };
const initialResult = this._context
.useIncrementalNotifications
? errors === undefined
? { data, pending: this._pendingSourcesToResults(newPending), hasNext: true }
: { errors, data, pending: this._pendingSourcesToResults(newPending), hasNext: true }
: errors === undefined
? { data, hasNext: true }
: { errors, data, hasNext: true };
return {

@@ -158,3 +162,2 @@ initialResult,

.deferredFragmentRecords) {
const id = deferredFragmentRecord.id;
if (!this._incrementalGraph.removeDeferredFragment(deferredFragmentRecord)) {

@@ -164,25 +167,22 @@ // This can occur if multiple deferred grouped field sets error for a fragment.

}
invariant(id !== undefined);
if (this._context.sendIncrementalErrorsAsNull) {
if (this._context.useIncrementalNotifications) {
const id = deferredFragmentRecord.id;
invariant(id !== undefined);
context.completed.push({
id,
errors: completedExecutionGroup.errors,
});
}
else {
const incrementalEntry = {
id,
errors: completedExecutionGroup.errors,
data: null,
errors: completedExecutionGroup.errors,
};
if (this._context.sendPathAndLabelOnIncremental) {
const { path, label } = deferredFragmentRecord;
incrementalEntry.path = pathToArray(path);
if (label !== undefined) {
incrementalEntry.label = label;
}
const { path, label } = deferredFragmentRecord;
incrementalEntry.path = pathToArray(path);
if (label !== undefined) {
incrementalEntry.label = label;
}
context.incremental.push(incrementalEntry);
context.completed.push({ id });
}
else {
context.completed.push({
id,
errors: completedExecutionGroup.errors,
});
}
}

@@ -198,14 +198,26 @@ return;

}
const id = deferredFragmentRecord.id;
invariant(id !== undefined);
const incremental = context.incremental;
const { newPending, successfulExecutionGroups } = completion;
context.pending.push(...this._pendingSourcesToResults(newPending));
for (const successfulExecutionGroup of successfulExecutionGroups) {
const { bestId, subPath } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup);
const incrementalEntry = {
...successfulExecutionGroup.result,
id: bestId,
};
if (this._context.sendPathAndLabelOnIncremental) {
const successfulExecutionGroups = completion.successfulExecutionGroups;
if (this._context.useIncrementalNotifications) {
const id = deferredFragmentRecord.id;
invariant(id !== undefined);
context.pending.push(...this._pendingSourcesToResults(completion.newPending));
for (const successfulExecutionGroup of successfulExecutionGroups) {
const { bestId, subPath } = this._getBestIdAndSubPath(id, deferredFragmentRecord, successfulExecutionGroup);
const incrementalEntry = {
...successfulExecutionGroup.result,
id: bestId,
};
if (subPath !== undefined) {
incrementalEntry.subPath = subPath;
}
incremental.push(incrementalEntry);
}
context.completed.push({ id });
}
else {
for (const successfulExecutionGroup of successfulExecutionGroups) {
const incrementalEntry = {
...successfulExecutionGroup.result,
};
const { path, label } = deferredFragmentRecord;

@@ -216,9 +228,5 @@ incrementalEntry.path = pathToArray(path);

}
incremental.push(incrementalEntry);
}
if (subPath !== undefined) {
incrementalEntry.subPath = subPath;
}
incremental.push(incrementalEntry);
}
context.completed.push({ id });
}

@@ -228,27 +236,23 @@ }

const streamRecord = streamItemsResult.streamRecord;
const id = streamRecord.id;
invariant(id !== undefined);
if (streamItemsResult.errors !== undefined) {
if (this._context.sendIncrementalErrorsAsNull) {
if (this._context.useIncrementalNotifications) {
const id = streamRecord.id;
invariant(id !== undefined);
context.completed.push({
id,
errors: streamItemsResult.errors,
});
}
else {
const incrementalEntry = {
errors: streamItemsResult.errors,
items: null,
id,
errors: streamItemsResult.errors,
};
if (this._context.sendPathAndLabelOnIncremental) {
const { path, label, index } = streamRecord;
incrementalEntry.path = pathToArray(addPath(path, index, undefined));
if (label !== undefined) {
incrementalEntry.label = label;
}
const { path, label, index } = streamRecord;
incrementalEntry.path = pathToArray(addPath(path, index, undefined));
if (label !== undefined) {
incrementalEntry.label = label;
}
context.incremental.push(incrementalEntry);
context.completed.push({ id });
}
else {
context.completed.push({
id,
errors: streamItemsResult.errors,
});
}
this._incrementalGraph.removeStream(streamRecord);

@@ -265,3 +269,7 @@ if (isCancellableStreamRecord(streamRecord)) {

else if (streamItemsResult.result === undefined) {
context.completed.push({ id });
if (this._context.useIncrementalNotifications) {
const id = streamRecord.id;
invariant(id !== undefined);
context.completed.push({ id });
}
this._incrementalGraph.removeStream(streamRecord);

@@ -276,6 +284,10 @@ if (isCancellableStreamRecord(streamRecord)) {

const incrementalEntry = {
id,
...bareResult,
};
if (this._context.sendPathAndLabelOnIncremental) {
if (this._context.useIncrementalNotifications) {
const id = streamRecord.id;
invariant(id !== undefined);
incrementalEntry.id = id;
}
else {
const { path, label, index } = streamRecord;

@@ -292,3 +304,5 @@ incrementalEntry.path = pathToArray(addPath(path, index, undefined));

const newPending = this._incrementalGraph.getNewPending(incrementalDataRecords);
context.pending.push(...this._pendingSourcesToResults(newPending));
if (this._context.useIncrementalNotifications) {
context.pending.push(...this._pendingSourcesToResults(newPending));
}
}

@@ -295,0 +309,0 @@ }

{
"name": "@graphql-tools/executor",
"version": "2.0.0-alpha-20240804115623-ba8ea361d8cc77c657068ef6648d977439b63ab3",
"version": "2.0.0-alpha-20240805144842-131e76d507ce82e59a400bf90758e7af71493abf",
"sideEffects": false,

@@ -9,3 +9,3 @@ "peerDependencies": {

"dependencies": {
"@graphql-tools/utils": "10.4.0-alpha-20240804115623-ba8ea361d8cc77c657068ef6648d977439b63ab3",
"@graphql-tools/utils": "10.4.0-alpha-20240805144842-131e76d507ce82e59a400bf90758e7af71493abf",
"@graphql-typed-document-node/core": "3.2.0",

@@ -12,0 +12,0 @@ "@repeaterjs/repeater": "^3.0.4",

@@ -21,3 +21,3 @@ import type { FieldNode, FragmentDefinitionNode, GraphQLObjectType, GraphQLSchema, SelectionSetNode } from 'graphql';

*/
export declare function collectFields<TVariables = any>(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: TVariables, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, errorWithIncrementalSubscription: boolean): {
export declare function collectFields<TVariables = any>(schema: GraphQLSchema, fragments: Record<string, FragmentDefinitionNode>, variableValues: TVariables, runtimeType: GraphQLObjectType, selectionSet: SelectionSetNode, errorOnSubscriptionWithIncrementalDelivery: boolean): {
groupedFieldSet: GroupedFieldSet;

@@ -38,5 +38,5 @@ newDeferUsages: ReadonlyArray<DeferUsage>;

[variable: string]: unknown;
}, errorWithIncrementalSubscription: boolean, returnType: GraphQLObjectType, fieldGroup: FieldGroup): {
}, errorOnSubscriptionWithIncrementalDelivery: boolean, returnType: GraphQLObjectType, fieldGroup: FieldGroup): {
groupedFieldSet: GroupedFieldSet;
newDeferUsages: ReadonlyArray<DeferUsage>;
};

@@ -42,6 +42,5 @@ import { DocumentNode, FieldNode, FragmentDefinitionNode, GraphQLError, GraphQLField, GraphQLFieldResolver, GraphQLObjectType, GraphQLResolveInfo, GraphQLSchema, GraphQLTypeResolver, OperationDefinitionNode } from 'graphql';

enableEarlyExecution: boolean;
deduplicateDefers: boolean;
sendIncrementalErrorsAsNull: boolean;
sendPathAndLabelOnIncremental: boolean;
errorWithIncrementalSubscription: boolean;
deferWithoutDuplication: boolean;
useIncrementalNotifications: boolean;
errorOnSubscriptionWithIncrementalDelivery: boolean;
signal: AbortSignal | undefined;

@@ -52,2 +51,3 @@ errors: AccumulatorMap<Path | undefined, GraphQLError> | undefined;

}
export type IncrementalPreset = 'v17.0.0-alpha.2' | 'v17.0.0-alpha.3';
export interface ExecutionArgs<TData = any, TVariables = any, TContext = any> {

@@ -64,6 +64,6 @@ schema: GraphQLSchema;

enableEarlyExecution?: Maybe<boolean>;
deduplicateDefers?: Maybe<boolean>;
sendIncrementalErrorsAsNull?: Maybe<boolean>;
sendPathAndLabelOnIncremental?: Maybe<boolean>;
errorWithIncrementalSubscription?: Maybe<boolean>;
incrementalPreset?: Maybe<IncrementalPreset>;
deferWithoutDuplication?: Maybe<boolean>;
useIncrementalNotifications?: Maybe<boolean>;
errorOnSubscriptionWithIncrementalDelivery?: Maybe<boolean>;
signal?: AbortSignal;

@@ -166,3 +166,3 @@ }

export declare function subscribe<TData = any, TVariables = any, TContext = any>(args: ExecutionArgs<TData, TVariables, TContext> & {
errorWithIncrementalSubscription: true | undefined | null;
errorOnSubscriptionWithIncrementalDelivery: true | undefined | null;
}): MaybePromise<AsyncGenerator<SingularExecutionResult<TData>, void, void> | SingularExecutionResult<TData>>;

@@ -169,0 +169,0 @@ export declare function subscribe<TData = any, TVariables = any, TContext = any>(args: ExecutionArgs<TData, TVariables, TContext>): MaybePromise<AsyncGenerator<SingularExecutionResult<TData> | InitialIncrementalExecutionResult<TData> | SubsequentIncrementalExecutionResult<TData>, void, void> | SingularExecutionResult<TData>>;

@@ -5,4 +5,3 @@ import type { GraphQLError } from 'graphql';

interface IncrementalPublisherContext {
sendIncrementalErrorsAsNull: boolean;
sendPathAndLabelOnIncremental: boolean;
useIncrementalNotifications: boolean;
signal: AbortSignal | undefined;

@@ -9,0 +8,0 @@ cancellableStreams: Set<CancellableStreamRecord> | undefined;

@@ -29,3 +29,3 @@ import type { GraphQLError, GraphQLFormattedError } from 'graphql';

data: TData;
pending: ReadonlyArray<PendingResult>;
pending?: ReadonlyArray<PendingResult>;
hasNext: true;

@@ -36,3 +36,3 @@ extensions?: TExtensions;

data: TData;
pending: ReadonlyArray<PendingResult>;
pending?: ReadonlyArray<PendingResult>;
hasNext: boolean;

@@ -62,3 +62,3 @@ extensions?: TExtensions;

data: TData | null;
id: string;
id?: string;
path?: ReadonlyArray<string | number>;

@@ -85,3 +85,3 @@ label?: string;

items: TData | null;
id: string;
id?: string;
path?: ReadonlyArray<string | number>;

@@ -88,0 +88,0 @@ label?: string;

Sorry, the diff of this file is too big to display

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