grafast 1.0.0-rc.2 → 1.0.0-rc.4
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/dist/engine/distributor.d.ts +1 -1
- package/dist/engine/distributor.js +34 -11
- package/dist/grafastPrint.js +0 -3
- package/dist/index.d.ts +9 -2
- package/dist/index.js +6 -6
- package/dist/inspect.d.ts +1 -1
- package/dist/makeGrafastSchema.js +6 -6
- package/dist/prepare.js +56 -23
- package/dist/promiseWithResolve.d.ts +12 -0
- package/dist/promiseWithResolve.js +8 -0
- package/dist/step.d.ts +2 -0
- package/dist/step.js +3 -1
- package/dist/steps/_loadCommon.d.ts +3 -4
- package/dist/steps/_loadCommon.js +4 -3
- package/dist/steps/connection.js +11 -5
- package/dist/steps/object.js +7 -4
- package/dist/utils.d.ts +0 -5
- package/dist/utils.js +11 -13
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
- package/dist/deferred.d.ts +0 -13
- package/dist/deferred.js +0 -24
|
@@ -4,9 +4,9 @@ exports.isDistributor = isDistributor;
|
|
|
4
4
|
exports.distributor = distributor;
|
|
5
5
|
exports.resolveDistributorOptions = resolveDistributorOptions;
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
|
-
const __1 = require("..");
|
|
8
7
|
const assert = tslib_1.__importStar(require("../assert"));
|
|
9
|
-
const
|
|
8
|
+
const dev_1 = require("../dev");
|
|
9
|
+
const promiseWithResolve_1 = require("../promiseWithResolve");
|
|
10
10
|
const utils_1 = require("../utils");
|
|
11
11
|
const DEFAULT_DISTRIBUTOR_BUFFER_SIZE = 1001;
|
|
12
12
|
const DEFAULT_DISTRIBUTOR_BUFFER_SIZE_INCREMENT = 1001;
|
|
@@ -72,10 +72,9 @@ function distributor(sourceIterable, dependentSteps, abortSignal, distributorOpt
|
|
|
72
72
|
let wmi = null;
|
|
73
73
|
function lowWaterMarkIncreased() {
|
|
74
74
|
if (wmi === null) {
|
|
75
|
-
|
|
76
|
-
wmi = d;
|
|
75
|
+
wmi = (0, promiseWithResolve_1.promiseWithResolve)();
|
|
77
76
|
}
|
|
78
|
-
return wmi;
|
|
77
|
+
return wmi.promise;
|
|
79
78
|
}
|
|
80
79
|
/**
|
|
81
80
|
* The maximum index that can be retrieved from our sourceIterator. Infinity
|
|
@@ -115,10 +114,26 @@ function distributor(sourceIterable, dependentSteps, abortSignal, distributorOpt
|
|
|
115
114
|
// iterator[Symbol.dispose]!();
|
|
116
115
|
//} else
|
|
117
116
|
if (iterator.return) {
|
|
118
|
-
|
|
117
|
+
try {
|
|
118
|
+
const r = iterator.return();
|
|
119
|
+
if ((0, utils_1.isPromiseLike)(r)) {
|
|
120
|
+
r.then(null, dev_1.noop);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
/*noop*/
|
|
125
|
+
}
|
|
119
126
|
}
|
|
120
127
|
else if (iterator?.throw) {
|
|
121
|
-
|
|
128
|
+
try {
|
|
129
|
+
const r = iterator.throw(new Error("Stop"));
|
|
130
|
+
if ((0, utils_1.isPromiseLike)(r)) {
|
|
131
|
+
r.then(null, dev_1.noop);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
/*noop*/
|
|
136
|
+
}
|
|
122
137
|
}
|
|
123
138
|
else {
|
|
124
139
|
// Just ignore it? Or do we need to call `.next()` indefinitely?
|
|
@@ -196,7 +211,7 @@ function distributor(sourceIterable, dependentSteps, abortSignal, distributorOpt
|
|
|
196
211
|
const bufferIndex = index - lowWaterMark;
|
|
197
212
|
let result;
|
|
198
213
|
if (bufferIndex >= bufferLength) {
|
|
199
|
-
if (
|
|
214
|
+
if (dev_1.isDev) {
|
|
200
215
|
assert.strictEqual(bufferIndex, bufferLength, "We've missed some indexes?!");
|
|
201
216
|
}
|
|
202
217
|
// It's our job to pull the next value!
|
|
@@ -245,7 +260,7 @@ function distributor(sourceIterable, dependentSteps, abortSignal, distributorOpt
|
|
|
245
260
|
if (result == null) {
|
|
246
261
|
return stop(stepIndex, new Error(`GrafastInternalError<330dba8c-baf0-4352-9cb7-3445e7f14bfc>: bug in Distributor; deliveredIndex: ${deliveredIndex[stepIndex]}, requestedIndex: ${requestedIndex[stepIndex]}, currentIndex: ${index}, bufferIndex: ${bufferIndex}, buffer.length: ${buffer.length}`));
|
|
247
262
|
}
|
|
248
|
-
if (
|
|
263
|
+
if (dev_1.isDev) {
|
|
249
264
|
assert.strictEqual(deliveredIndex[stepIndex], index - 1, "Expectation of delivered index did not match");
|
|
250
265
|
}
|
|
251
266
|
deliveredIndex[stepIndex] = index;
|
|
@@ -255,7 +270,15 @@ function distributor(sourceIterable, dependentSteps, abortSignal, distributorOpt
|
|
|
255
270
|
function stop(stepIndex, error, advance = true) {
|
|
256
271
|
if (!terminalResult[stepIndex]) {
|
|
257
272
|
deliveredIndex[stepIndex] = Infinity;
|
|
258
|
-
|
|
273
|
+
if (error) {
|
|
274
|
+
const p = Promise.reject(error);
|
|
275
|
+
// Catch this error so it doesn't cause premature termination
|
|
276
|
+
p.then(null, dev_1.noop);
|
|
277
|
+
terminalResult[stepIndex] = p;
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
terminalResult[stepIndex] = DONE_PROMISE;
|
|
281
|
+
}
|
|
259
282
|
if (advance) {
|
|
260
283
|
maybeAdvanceLowWaterMark();
|
|
261
284
|
}
|
|
@@ -278,7 +301,7 @@ function distributor(sourceIterable, dependentSteps, abortSignal, distributorOpt
|
|
|
278
301
|
: sourceIterable[Symbol.iterator]();
|
|
279
302
|
}
|
|
280
303
|
const onAbort = () => {
|
|
281
|
-
iterator.return();
|
|
304
|
+
iterator.return().then(null, dev_1.noop);
|
|
282
305
|
};
|
|
283
306
|
const iterator = {
|
|
284
307
|
[Symbol.asyncIterator]() {
|
package/dist/grafastPrint.js
CHANGED
|
@@ -48,9 +48,6 @@ const BG_COLORS = [
|
|
|
48
48
|
chalk_1.default.underline,
|
|
49
49
|
];
|
|
50
50
|
function _grafastPrint(symbol, seen) {
|
|
51
|
-
if ((0, utils_js_1.isDeferred)(symbol)) {
|
|
52
|
-
return chalk_1.default.gray `<Deferred>`;
|
|
53
|
-
}
|
|
54
51
|
if ((0, utils_js_1.isPromise)(symbol)) {
|
|
55
52
|
return chalk_1.default.gray `<Promise>`;
|
|
56
53
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type LRU from "@graphile/lru";
|
|
|
3
3
|
import type { MiddlewareHandlers } from "graphile-config";
|
|
4
4
|
import type { DocumentNode, ExecutionResult, GraphQLError, OperationDefinitionNode } from "graphql";
|
|
5
5
|
import type { ObjMap } from "graphql/jsutils/ObjMap";
|
|
6
|
+
import { promiseWithResolve } from "./promiseWithResolve.js";
|
|
6
7
|
import type { DataFromObjectSteps } from "./steps/object.js";
|
|
7
8
|
type PromiseOrValue<T> = T | Promise<T>;
|
|
8
9
|
import { exportAs, exportAsMany } from "./exportAs.js";
|
|
@@ -10,7 +11,6 @@ import { grafastPrint } from "./grafastPrint.js";
|
|
|
10
11
|
import { AbstractTypePlan, DeprecatedInputObjectPlan, DeprecatedObjectPlan, EnumPlan, EnumValueConfig, EnumValueInput, FieldPlan, GrafastSchemaConfig, InputFieldPlan, InputObjectFieldConfig, InputObjectPlan, InterfacePlan, makeGrafastSchema, ObjectFieldConfig, ObjectPlan, ScalarPlan, UnionPlan } from "./makeGrafastSchema.js";
|
|
11
12
|
import type { $$cacheByOperation, $$hooked, $$queryCache } from "./constants.js";
|
|
12
13
|
import { $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$verbatim, DEFAULT_ACCEPT_FLAGS } from "./constants.js";
|
|
13
|
-
import { defer, Deferred } from "./deferred.js";
|
|
14
14
|
import { isDev, noop } from "./dev.js";
|
|
15
15
|
import { defaultPlanResolver } from "./engine/lib/defaultPlanResolver.js";
|
|
16
16
|
import { currentFieldStreamDetails, isUnaryStep } from "./engine/lib/withGlobalLayerPlan.js";
|
|
@@ -33,7 +33,8 @@ import { subscribe } from "./subscribe.js";
|
|
|
33
33
|
import { arrayOfLength, arraysMatch, asyncIteratorWithCleanup, getEnumValueConfig, getEnumValueConfigs, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, GraphQLSpecifiedErrorBehaviors, inputObjectFieldSpec, InputObjectTypeSpec, isPromiseLike, mapsMatch, maybeArraysMatch, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, objectFieldSpec, objectSpec, ObjectTypeFields, ObjectTypeSpec, recordsMatch, setsMatch, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, stepsAreInSamePhase } from "./utils.js";
|
|
34
34
|
export { GraphQLDeferDirective, graphqlHasStreamDefer, GraphQLStreamDirective, } from "./incremental.js";
|
|
35
35
|
export { isAsyncIterable } from "iterall";
|
|
36
|
-
export { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$inhibit, $$verbatim, AbstractTypePlan, AbstractTypePlanner, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, arrayOfLength, arraysMatch, assertExecutableStep, assertListCapableStep, assertModifier, assertNotNull, assertStep, asyncIteratorWithCleanup, bakedInput, bakedInputRuntime, BakedInputStep, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, coalesce, CoalesceStep, condition, ConditionStep, connection, ConnectionHandlingResult, ConnectionHandlingStep, ConnectionOptimizedStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, currentFieldStreamDetails, DataFromObjectSteps, DataFromStep, debugPlans, DEFAULT_ACCEPT_FLAGS, defaultPlanResolver,
|
|
36
|
+
export { __FlagStep, __InputListStep, __InputObjectStep, __InputObjectStepWithDollars, __InputStaticLeafStep, __ItemStep, __ListTransformStep, __TrackedValueStep, __TrackedValueStepWithDollars, __ValueStep, $$bypassGraphQL, $$eventEmitter, $$extensions, $$idempotent, $$inhibit, $$verbatim, AbstractTypePlan, AbstractTypePlanner, access, AccessStep, ActualKeyByDesiredKey, applyInput, ApplyInputStep, applyTransforms, ApplyTransformsStep, arrayOfLength, arraysMatch, assertExecutableStep, assertListCapableStep, assertModifier, assertNotNull, assertStep, asyncIteratorWithCleanup, bakedInput, bakedInputRuntime, BakedInputStep, BaseEventMap, BaseGraphQLArguments, BaseGraphQLRootValue, BaseGraphQLVariables, BatchExecutionValue, coalesce, CoalesceStep, condition, ConditionStep, connection, ConnectionHandlingResult, ConnectionHandlingStep, ConnectionOptimizedStep, ConnectionStep, constant, ConstantStep, context, createObjectAndApplyChildren, currentFieldStreamDetails, DataFromObjectSteps, DataFromStep, debugPlans, DEFAULT_ACCEPT_FLAGS, defaultPlanResolver, DeprecatedInputObjectPlan, DeprecatedObjectPlan, each, EdgeStep, EnumPlan, EnumValueConfig, EnumValueInput, error, ErrorBehavior, ErrorStep, EventCallback, EventMapKey, Step as ExecutableStep, execute, ExecutionDetails, ExecutionDetailsStream, ExecutionEventEmitter, ExecutionEventMap, ExecutionExtra, ExecutionResults, ExecutionResultValue, ExecutionValue, exportAs, exportAsMany, FieldArg, FieldArgs, FieldInfo, FieldPlan, FieldPlanResolver, filter, FilterPlanMemo, first, FirstStep, flagError, get, getEnumValueConfig, getEnumValueConfigs, getGrafastMiddleware, getNullableInputTypeAtPath, grafast, GrafastArgumentConfig, GrafastExecutionArgs, GrafastFieldConfig, GrafastFieldConfigArgumentMap, grafast as grafastGraphql, grafastSync as grafastGraphqlSync, GrafastInputFieldConfig, GrafastInputFieldConfigMap, GrafastInputObjectType, GrafastObjectType, GrafastPlanJSON, grafastPrint, GrafastResultsList, GrafastResultStreamList, GrafastSchemaConfig, GrafastSubscriber, grafastSync, GrafastValuesList, graphqlResolver, GraphQLResolverStep, GraphQLSpecifiedErrorBehaviors, groupBy, GroupByPlanMemo, inhibitOnNull, InputFieldPlan, InputObjectFieldApplyResolver, InputObjectFieldConfig, inputObjectFieldSpec, InputObjectPlan, InputObjectTypeBakedInfo, InputObjectTypeBakedResolver, InputObjectTypeSpec, inspect, InterfacePlan, isDev, isExecutableStep, isListCapableStep, isListLikeStep, isModifier, isObjectLikeStep, isPromiseLike, isSafeError, isStep, isUnaryStep, JSONArray, JSONObject, JSONValue, lambda, LambdaStep, last, LastStep, list, ListCapableStep, listen, ListenStep, ListLikeStep, ListStep, listTransform, ListTransformItemPlanCallback, ListTransformOptions, ListTransformReduce, LoadedRecordStep, loadMany, LoadManyCallback, loadManyCallback, LoadManyInfo, LoadManyLoader, loadManyLoader, LoadManyStep, loadOne, LoadOneCallback, loadOneCallback, LoadOneInfo, LoadOneLoader, loadOneLoader, LoadOneStep, makeDecodeNodeId, makeDecodeNodeIdRuntime, makeGrafastSchema, mapsMatch, Maybe, maybeArraysMatch, Modifier, Multistep, multistep, newGrafastFieldConfigBuilder, newInputObjectTypeBuilder, newObjectTypeBuilder, NodeIdCodec, nodeIdFromNode, NodeIdHandler, noop, object, ObjectFieldConfig, objectFieldSpec, ObjectLikeStep, ObjectPlan, ObjectPlanMeta, objectSpec, ObjectStep, ObjectTypeFields, ObjectTypeSpec, OperationPlan, operationPlan, PaginationFeatures, PaginationParams, partitionByIndex, PlanTypeInfo, PromiseOrDirect, promiseWithResolve, proxy, ProxyStep, recordsMatch, remapKeys, RemapKeysStep, reverse, reverseArray, ReverseStep, rootValue, SafeError, ScalarPlan, ScalarPlanResolver, setsMatch, Setter, setter, SetterCapable, sideEffect, SideEffectStep, specFromNodeId, Step, stepADependsOnStepB, stepAMayDependOnStepB, stepAShouldTryAndInlineIntoStepB, StepOptimizeOptions, StepRepresentingList, stepsAreInSamePhase, StepStreamOptions, stringifyPayload, stripAnsi, subscribe, Thunk, trap, TRAP_ERROR, TRAP_ERROR_OR_INHIBITED, TRAP_INHIBITED, TypedEventEmitter, UnaryExecutionValue, UnbatchedStep as UnbatchedExecutableStep, UnbatchedExecutionExtra, UnbatchedStep, UnionPlan, UnwrapMultistep, };
|
|
37
|
+
export type { PromiseWithResolve } from "./promiseWithResolve.js";
|
|
37
38
|
export { hookArgs } from "./args.js";
|
|
38
39
|
export { version } from "./version.js";
|
|
39
40
|
declare global {
|
|
@@ -260,6 +261,8 @@ declare global {
|
|
|
260
261
|
*
|
|
261
262
|
* This must be set higher than the largest `@stream(initialCount:)`
|
|
262
263
|
* argument you want to support.
|
|
264
|
+
*
|
|
265
|
+
* @advanced
|
|
263
266
|
*/
|
|
264
267
|
distributorTargetBufferSize?: number;
|
|
265
268
|
/**
|
|
@@ -268,6 +271,8 @@ declare global {
|
|
|
268
271
|
* pause again.
|
|
269
272
|
*
|
|
270
273
|
* Must be at least 1. Recommend you set this fairly large.
|
|
274
|
+
*
|
|
275
|
+
* @advanced
|
|
271
276
|
*/
|
|
272
277
|
distributorTargetBufferSizeIncrement?: number;
|
|
273
278
|
/**
|
|
@@ -276,6 +281,8 @@ declare global {
|
|
|
276
281
|
* `distributorTargetBufferSize` has been reached.
|
|
277
282
|
*
|
|
278
283
|
* Must be at least 0.
|
|
284
|
+
*
|
|
285
|
+
* @advanced
|
|
279
286
|
*/
|
|
280
287
|
distributorPauseDuration?: number;
|
|
281
288
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.loadMany = exports.LoadedRecordStep = exports.listTransform = exports.ListStep = exports.ListenStep = exports.listen = exports.list = exports.LastStep = exports.last = exports.LambdaStep = exports.lambda = exports.isUnaryStep = exports.isStep = exports.isSafeError = exports.isPromiseLike = exports.isObjectLikeStep = exports.isModifier = exports.isListLikeStep = exports.isListCapableStep = exports.isExecutableStep = exports.isDev = exports.inspect = exports.inputObjectFieldSpec = exports.inhibitOnNull = exports.groupBy = exports.GraphQLSpecifiedErrorBehaviors = exports.GraphQLResolverStep = exports.graphqlResolver = exports.grafastSync = exports.grafastPrint = exports.grafastGraphqlSync = exports.grafastGraphql = exports.grafast = exports.getNullableInputTypeAtPath = exports.getGrafastMiddleware = exports.getEnumValueConfigs = exports.getEnumValueConfig = exports.get = exports.flagError = exports.FirstStep = exports.first = exports.filter = exports.exportAsMany = exports.exportAs = exports.execute = exports.ExecutableStep = exports.ErrorStep = exports.error = exports.EdgeStep =
|
|
5
|
-
exports.subscribe = exports.stripAnsi = exports.stringifyPayload = exports.stepsAreInSamePhase = exports.stepAShouldTryAndInlineIntoStepB = exports.stepAMayDependOnStepB = exports.stepADependsOnStepB = exports.Step = exports.specFromNodeId = exports.SideEffectStep = exports.sideEffect = exports.setter = exports.Setter = exports.setsMatch = exports.SafeError = exports.rootValue = exports.ReverseStep = exports.reverseArray = exports.reverse = exports.RemapKeysStep = exports.remapKeys = exports.recordsMatch = exports.ProxyStep = exports.proxy = exports.partitionByIndex = exports.operationPlan = exports.OperationPlan = exports.ObjectStep = exports.objectSpec = exports.objectFieldSpec = exports.object = exports.noop = exports.nodeIdFromNode = exports.newObjectTypeBuilder = exports.newInputObjectTypeBuilder = exports.newGrafastFieldConfigBuilder = exports.multistep = exports.Modifier = exports.maybeArraysMatch = exports.mapsMatch = exports.makeGrafastSchema = exports.makeDecodeNodeIdRuntime = exports.makeDecodeNodeId = exports.LoadOneStep = exports.loadOneLoader = exports.loadOneCallback = exports.loadOne = exports.LoadManyStep = exports.loadManyLoader =
|
|
3
|
+
exports.each = exports.defaultPlanResolver = exports.DEFAULT_ACCEPT_FLAGS = exports.debugPlans = exports.currentFieldStreamDetails = exports.createObjectAndApplyChildren = exports.context = exports.ConstantStep = exports.constant = exports.ConnectionStep = exports.connection = exports.ConditionStep = exports.condition = exports.CoalesceStep = exports.coalesce = exports.BakedInputStep = exports.bakedInputRuntime = exports.bakedInput = exports.asyncIteratorWithCleanup = exports.assertStep = exports.assertNotNull = exports.assertModifier = exports.assertListCapableStep = exports.assertExecutableStep = exports.arraysMatch = exports.arrayOfLength = exports.ApplyTransformsStep = exports.applyTransforms = exports.ApplyInputStep = exports.applyInput = exports.AccessStep = exports.access = exports.$$verbatim = exports.$$inhibit = exports.$$idempotent = exports.$$extensions = exports.$$eventEmitter = exports.$$bypassGraphQL = exports.__ValueStep = exports.__TrackedValueStep = exports.__ListTransformStep = exports.__ItemStep = exports.__InputStaticLeafStep = exports.__InputObjectStep = exports.__InputListStep = exports.__FlagStep = exports.isAsyncIterable = exports.GraphQLStreamDirective = exports.graphqlHasStreamDefer = exports.GraphQLDeferDirective = void 0;
|
|
4
|
+
exports.loadManyCallback = exports.loadMany = exports.LoadedRecordStep = exports.listTransform = exports.ListStep = exports.ListenStep = exports.listen = exports.list = exports.LastStep = exports.last = exports.LambdaStep = exports.lambda = exports.isUnaryStep = exports.isStep = exports.isSafeError = exports.isPromiseLike = exports.isObjectLikeStep = exports.isModifier = exports.isListLikeStep = exports.isListCapableStep = exports.isExecutableStep = exports.isDev = exports.inspect = exports.inputObjectFieldSpec = exports.inhibitOnNull = exports.groupBy = exports.GraphQLSpecifiedErrorBehaviors = exports.GraphQLResolverStep = exports.graphqlResolver = exports.grafastSync = exports.grafastPrint = exports.grafastGraphqlSync = exports.grafastGraphql = exports.grafast = exports.getNullableInputTypeAtPath = exports.getGrafastMiddleware = exports.getEnumValueConfigs = exports.getEnumValueConfig = exports.get = exports.flagError = exports.FirstStep = exports.first = exports.filter = exports.exportAsMany = exports.exportAs = exports.execute = exports.ExecutableStep = exports.ErrorStep = exports.error = exports.EdgeStep = void 0;
|
|
5
|
+
exports.subscribe = exports.stripAnsi = exports.stringifyPayload = exports.stepsAreInSamePhase = exports.stepAShouldTryAndInlineIntoStepB = exports.stepAMayDependOnStepB = exports.stepADependsOnStepB = exports.Step = exports.specFromNodeId = exports.SideEffectStep = exports.sideEffect = exports.setter = exports.Setter = exports.setsMatch = exports.SafeError = exports.rootValue = exports.ReverseStep = exports.reverseArray = exports.reverse = exports.RemapKeysStep = exports.remapKeys = exports.recordsMatch = exports.ProxyStep = exports.proxy = exports.promiseWithResolve = exports.partitionByIndex = exports.operationPlan = exports.OperationPlan = exports.ObjectStep = exports.objectSpec = exports.objectFieldSpec = exports.object = exports.noop = exports.nodeIdFromNode = exports.newObjectTypeBuilder = exports.newInputObjectTypeBuilder = exports.newGrafastFieldConfigBuilder = exports.multistep = exports.Modifier = exports.maybeArraysMatch = exports.mapsMatch = exports.makeGrafastSchema = exports.makeDecodeNodeIdRuntime = exports.makeDecodeNodeId = exports.LoadOneStep = exports.loadOneLoader = exports.loadOneCallback = exports.loadOne = exports.LoadManyStep = exports.loadManyLoader = void 0;
|
|
6
6
|
exports.version = exports.hookArgs = exports.UnbatchedStep = exports.UnbatchedExecutableStep = exports.TRAP_INHIBITED = exports.TRAP_ERROR_OR_INHIBITED = exports.TRAP_ERROR = exports.trap = void 0;
|
|
7
7
|
const tslib_1 = require("tslib");
|
|
8
8
|
require("./thereCanBeOnlyOne.js");
|
|
9
9
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
10
|
+
const promiseWithResolve_js_1 = require("./promiseWithResolve.js");
|
|
11
|
+
Object.defineProperty(exports, "promiseWithResolve", { enumerable: true, get: function () { return promiseWithResolve_js_1.promiseWithResolve; } });
|
|
10
12
|
const exportAs_js_1 = require("./exportAs.js");
|
|
11
13
|
Object.defineProperty(exports, "exportAs", { enumerable: true, get: function () { return exportAs_js_1.exportAs; } });
|
|
12
14
|
Object.defineProperty(exports, "exportAsMany", { enumerable: true, get: function () { return exportAs_js_1.exportAsMany; } });
|
|
@@ -23,8 +25,6 @@ Object.defineProperty(exports, "$$extensions", { enumerable: true, get: function
|
|
|
23
25
|
Object.defineProperty(exports, "$$idempotent", { enumerable: true, get: function () { return constants_js_1.$$idempotent; } });
|
|
24
26
|
Object.defineProperty(exports, "$$verbatim", { enumerable: true, get: function () { return constants_js_1.$$verbatim; } });
|
|
25
27
|
Object.defineProperty(exports, "DEFAULT_ACCEPT_FLAGS", { enumerable: true, get: function () { return constants_js_1.DEFAULT_ACCEPT_FLAGS; } });
|
|
26
|
-
const deferred_js_1 = require("./deferred.js");
|
|
27
|
-
Object.defineProperty(exports, "defer", { enumerable: true, get: function () { return deferred_js_1.defer; } });
|
|
28
28
|
// Handy for debugging
|
|
29
29
|
const dev_js_1 = require("./dev.js");
|
|
30
30
|
Object.defineProperty(exports, "isDev", { enumerable: true, get: function () { return dev_js_1.isDev; } });
|
|
@@ -193,11 +193,11 @@ var iterall_1 = require("iterall");
|
|
|
193
193
|
Object.defineProperty(exports, "isAsyncIterable", { enumerable: true, get: function () { return iterall_1.isAsyncIterable; } });
|
|
194
194
|
(0, exportAs_js_1.exportAsMany)("grafast", {
|
|
195
195
|
exportAs: exportAs_js_1.exportAs,
|
|
196
|
+
promiseWithResolve: promiseWithResolve_js_1.promiseWithResolve,
|
|
196
197
|
exportAsMany: exportAs_js_1.exportAsMany,
|
|
197
198
|
grafastPrint: grafastPrint_js_1.grafastPrint,
|
|
198
199
|
makeGrafastSchema: makeGrafastSchema_js_1.makeGrafastSchema,
|
|
199
200
|
OperationPlan: OperationPlan_js_1.OperationPlan,
|
|
200
|
-
defer: deferred_js_1.defer,
|
|
201
201
|
execute: execute_js_1.execute,
|
|
202
202
|
getNullableInputTypeAtPath: operationPlan_input_js_1.getNullableInputTypeAtPath,
|
|
203
203
|
getGrafastMiddleware: middleware_js_1.getGrafastMiddleware,
|
package/dist/inspect.d.ts
CHANGED
|
@@ -48,7 +48,7 @@ function makeGrafastSchema(details) {
|
|
|
48
48
|
else {
|
|
49
49
|
// Hackily convert the new format into the old format. We'll do away with
|
|
50
50
|
// this in future, but for now it's the easiest way to ensure compatibility
|
|
51
|
-
plans =
|
|
51
|
+
plans = Object.create(null);
|
|
52
52
|
const assertLocation = (typeName, expectedLocation) => {
|
|
53
53
|
const t = astSchema.getType(typeName);
|
|
54
54
|
if (!t) {
|
|
@@ -84,7 +84,7 @@ function makeGrafastSchema(details) {
|
|
|
84
84
|
};
|
|
85
85
|
for (const [typeName, spec] of Object.entries(objects ?? {})) {
|
|
86
86
|
const t = assertLocation(typeName, "objects");
|
|
87
|
-
const o =
|
|
87
|
+
const o = Object.create(null);
|
|
88
88
|
plans[typeName] = o;
|
|
89
89
|
const { plans: planResolvers = {}, ...rest } = spec;
|
|
90
90
|
for (const [key, val] of Object.entries(rest)) {
|
|
@@ -99,7 +99,7 @@ function makeGrafastSchema(details) {
|
|
|
99
99
|
}
|
|
100
100
|
for (const [typeName, spec] of Object.entries(inputObjects ?? {})) {
|
|
101
101
|
const t = assertLocation(typeName, "inputObjects");
|
|
102
|
-
const o =
|
|
102
|
+
const o = Object.create(null);
|
|
103
103
|
plans[typeName] = o;
|
|
104
104
|
const { plans: planResolvers = {}, ...rest } = spec;
|
|
105
105
|
for (const [key, val] of Object.entries(rest)) {
|
|
@@ -114,7 +114,7 @@ function makeGrafastSchema(details) {
|
|
|
114
114
|
}
|
|
115
115
|
for (const [typeName, spec] of Object.entries(unions ?? {})) {
|
|
116
116
|
assertLocation(typeName, "unions");
|
|
117
|
-
const o =
|
|
117
|
+
const o = Object.create(null);
|
|
118
118
|
plans[typeName] = o;
|
|
119
119
|
for (const [key, val] of Object.entries(spec)) {
|
|
120
120
|
o[`__${key}`] = val;
|
|
@@ -122,7 +122,7 @@ function makeGrafastSchema(details) {
|
|
|
122
122
|
}
|
|
123
123
|
for (const [typeName, spec] of Object.entries(interfaces ?? {})) {
|
|
124
124
|
assertLocation(typeName, "interfaces");
|
|
125
|
-
const o =
|
|
125
|
+
const o = Object.create(null);
|
|
126
126
|
plans[typeName] = o;
|
|
127
127
|
for (const [key, val] of Object.entries(spec)) {
|
|
128
128
|
o[`__${key}`] = val;
|
|
@@ -134,7 +134,7 @@ function makeGrafastSchema(details) {
|
|
|
134
134
|
}
|
|
135
135
|
for (const [typeName, spec] of Object.entries(enums ?? {})) {
|
|
136
136
|
const t = assertLocation(typeName, "enums");
|
|
137
|
-
const o =
|
|
137
|
+
const o = Object.create(null);
|
|
138
138
|
plans[typeName] = o;
|
|
139
139
|
const { values = {}, ...rest } = spec;
|
|
140
140
|
if ("plans" in rest) {
|
package/dist/prepare.js
CHANGED
|
@@ -7,13 +7,13 @@ const execute_1 = require("graphql/execution/execute");
|
|
|
7
7
|
const iterall_1 = require("iterall");
|
|
8
8
|
const assert = tslib_1.__importStar(require("./assert.js"));
|
|
9
9
|
const constants_js_1 = require("./constants.js");
|
|
10
|
-
const deferred_js_1 = require("./deferred.js");
|
|
11
10
|
const dev_js_1 = require("./dev.js");
|
|
12
11
|
const executeBucket_js_1 = require("./engine/executeBucket.js");
|
|
13
12
|
const executeOutputPlan_js_1 = require("./engine/executeOutputPlan.js");
|
|
14
13
|
const OperationPlan_js_1 = require("./engine/OperationPlan.js");
|
|
15
14
|
const OutputPlan_js_1 = require("./engine/OutputPlan.js");
|
|
16
15
|
const establishOperationPlan_js_1 = require("./establishOperationPlan.js");
|
|
16
|
+
const promiseWithResolve_js_1 = require("./promiseWithResolve.js");
|
|
17
17
|
const timeSource_js_1 = require("./timeSource.js");
|
|
18
18
|
const utils_js_1 = require("./utils.js");
|
|
19
19
|
const { GraphQLError } = graphql;
|
|
@@ -63,10 +63,24 @@ function releaseUnusedIterators(bucket, bucketIndex, streams) {
|
|
|
63
63
|
if (allStreams.size > 0) {
|
|
64
64
|
for (const stream of allStreams) {
|
|
65
65
|
if (stream.return) {
|
|
66
|
-
|
|
66
|
+
try {
|
|
67
|
+
const result = stream.return();
|
|
68
|
+
if ((0, utils_js_1.isPromiseLike)(result))
|
|
69
|
+
result.then(null, noop);
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
/*noop*/
|
|
73
|
+
}
|
|
67
74
|
}
|
|
68
75
|
else if (stream.throw) {
|
|
69
|
-
|
|
76
|
+
try {
|
|
77
|
+
const result = stream.throw(new Error(`Iterator no longer needed (due to OutputPlan branch being skipped)`));
|
|
78
|
+
if ((0, utils_js_1.isPromiseLike)(result))
|
|
79
|
+
result.then(null, noop);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
/*noop*/
|
|
83
|
+
}
|
|
70
84
|
}
|
|
71
85
|
}
|
|
72
86
|
}
|
|
@@ -96,14 +110,14 @@ const finalize = (data, ctx, extensions, outputDataAsString) => {
|
|
|
96
110
|
if ((0, utils_js_1.isPromiseLike)(promise)) {
|
|
97
111
|
promise.then(() => {
|
|
98
112
|
iterator.push({ hasNext: false });
|
|
99
|
-
iterator.return(undefined);
|
|
113
|
+
iterator.return(undefined).then(null, noop);
|
|
100
114
|
}, (e) => {
|
|
101
|
-
iterator.throw(e);
|
|
115
|
+
iterator.throw(e).then(null, noop);
|
|
102
116
|
});
|
|
103
117
|
}
|
|
104
118
|
else {
|
|
105
119
|
iterator.push({ hasNext: false });
|
|
106
|
-
iterator.return(undefined);
|
|
120
|
+
iterator.return(undefined).then(null, noop);
|
|
107
121
|
}
|
|
108
122
|
return iterator;
|
|
109
123
|
}
|
|
@@ -273,27 +287,43 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
|
|
|
273
287
|
const stream = arr[constants_js_1.$$streamMore];
|
|
274
288
|
// Do the async iterable
|
|
275
289
|
let stopped = false;
|
|
276
|
-
const
|
|
290
|
+
const { promise: abortPromise, resolve: resolveAbort } = (0, promiseWithResolve_js_1.promiseWithResolve)();
|
|
277
291
|
const iterator = newIterator((e) => {
|
|
278
292
|
stopped = true;
|
|
279
|
-
|
|
293
|
+
resolveAbort();
|
|
280
294
|
if (e != null) {
|
|
281
|
-
|
|
295
|
+
try {
|
|
296
|
+
const result = stream.throw?.(e);
|
|
297
|
+
if ((0, utils_js_1.isPromiseLike)(result)) {
|
|
298
|
+
result.then(null, noop);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
/*noop*/
|
|
303
|
+
}
|
|
282
304
|
}
|
|
283
305
|
else {
|
|
284
|
-
|
|
306
|
+
try {
|
|
307
|
+
const result = stream.return?.();
|
|
308
|
+
if ((0, utils_js_1.isPromiseLike)(result)) {
|
|
309
|
+
result.then(null, noop);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
catch {
|
|
313
|
+
/*noop*/
|
|
314
|
+
}
|
|
285
315
|
}
|
|
286
316
|
});
|
|
287
317
|
(async () => {
|
|
288
318
|
let i = 0;
|
|
289
319
|
// eslint-disable-next-line no-constant-condition
|
|
290
320
|
while (true) {
|
|
291
|
-
const next = await Promise.race([
|
|
321
|
+
const next = await Promise.race([abortPromise, stream.next()]);
|
|
292
322
|
if (stopped || !next) {
|
|
293
323
|
break;
|
|
294
324
|
}
|
|
295
325
|
if (!next) {
|
|
296
|
-
iterator.throw(new Error("Invalid iteration"));
|
|
326
|
+
iterator.throw(new Error("Invalid iteration")).then(null, noop);
|
|
297
327
|
break;
|
|
298
328
|
}
|
|
299
329
|
const { done, value } = next;
|
|
@@ -301,7 +331,7 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
|
|
|
301
331
|
break;
|
|
302
332
|
}
|
|
303
333
|
const payload = await Promise.race([
|
|
304
|
-
|
|
334
|
+
abortPromise,
|
|
305
335
|
executeStreamPayload(value, i),
|
|
306
336
|
]);
|
|
307
337
|
if (payload === undefined) {
|
|
@@ -322,9 +352,9 @@ function executePreemptive(args, operationPlan, variableValues, context, rootVal
|
|
|
322
352
|
}
|
|
323
353
|
i++;
|
|
324
354
|
}
|
|
325
|
-
})()
|
|
326
|
-
iterator.throw(e)
|
|
327
|
-
|
|
355
|
+
})()
|
|
356
|
+
.then(() => iterator.return(), (e) => iterator.throw(e))
|
|
357
|
+
.then(null, noop);
|
|
328
358
|
return iterator;
|
|
329
359
|
}
|
|
330
360
|
// NOTE: this is the root output plan of a query/mutation operation
|
|
@@ -446,7 +476,7 @@ function newIterator(abort) {
|
|
|
446
476
|
catch (e) {
|
|
447
477
|
// ignore
|
|
448
478
|
}
|
|
449
|
-
this.throw(e);
|
|
479
|
+
this.throw(e).then(null, noop);
|
|
450
480
|
});
|
|
451
481
|
}
|
|
452
482
|
else {
|
|
@@ -510,7 +540,8 @@ function newIterator(abort) {
|
|
|
510
540
|
}
|
|
511
541
|
async function processStream(requestContext, iterator, spec, outputDataAsString) {
|
|
512
542
|
/** Resolve this when finished */
|
|
513
|
-
const whenDone =
|
|
543
|
+
const whenDone = Promise.withResolvers();
|
|
544
|
+
whenDone.promise.catch(noop); // Guard against unhandledPromiseRejection
|
|
514
545
|
let queue = null;
|
|
515
546
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
516
547
|
let timeout = null;
|
|
@@ -655,7 +686,7 @@ async function processStream(requestContext, iterator, spec, outputDataAsString)
|
|
|
655
686
|
}
|
|
656
687
|
// TODO: cleanup
|
|
657
688
|
}
|
|
658
|
-
return whenDone;
|
|
689
|
+
return whenDone.promise;
|
|
659
690
|
}
|
|
660
691
|
function processSingleDeferred(requestContext, outputPlan, specs, asString) {
|
|
661
692
|
const size = specs.length;
|
|
@@ -795,17 +826,19 @@ function processDeferred(requestContext, iterator, spec, outputDataAsString) {
|
|
|
795
826
|
}
|
|
796
827
|
if (outputDataAsString) {
|
|
797
828
|
if (!nextBatchAsString) {
|
|
798
|
-
nextBatchAsString =
|
|
829
|
+
nextBatchAsString = Promise.withResolvers();
|
|
830
|
+
nextBatchAsString.promise.catch(noop); // Guard against unhandledPromiseRejection
|
|
799
831
|
setTimeout(processBatchAsString, 1);
|
|
800
832
|
}
|
|
801
|
-
return nextBatchAsString;
|
|
833
|
+
return nextBatchAsString.promise;
|
|
802
834
|
}
|
|
803
835
|
else {
|
|
804
836
|
if (!nextBatchNotAsString) {
|
|
805
|
-
nextBatchNotAsString =
|
|
837
|
+
nextBatchNotAsString = Promise.withResolvers();
|
|
838
|
+
nextBatchNotAsString.promise.catch(noop); // Guard against unhandledPromiseRejection
|
|
806
839
|
setTimeout(processBatchNotAsString, 1);
|
|
807
840
|
}
|
|
808
|
-
return nextBatchNotAsString;
|
|
841
|
+
return nextBatchNotAsString.promise;
|
|
809
842
|
}
|
|
810
843
|
}
|
|
811
844
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface PromiseWithResolve<T> {
|
|
2
|
+
promise: Promise<T>;
|
|
3
|
+
/**
|
|
4
|
+
* NOTE: cannot pass a promise to `value`, otherwise it's possible to reject
|
|
5
|
+
* - in that case you should use `Promise.withResolvers()` rather than
|
|
6
|
+
* `promiseWithResolve`
|
|
7
|
+
*/
|
|
8
|
+
resolve(value: Awaited<T>): void;
|
|
9
|
+
}
|
|
10
|
+
/** When you can only succeed, there's no need to handle failure */
|
|
11
|
+
export declare function promiseWithResolve<T>(): PromiseWithResolve<T>;
|
|
12
|
+
//# sourceMappingURL=promiseWithResolve.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promiseWithResolve = promiseWithResolve;
|
|
4
|
+
/** When you can only succeed, there's no need to handle failure */
|
|
5
|
+
function promiseWithResolve() {
|
|
6
|
+
return Promise.withResolvers();
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=promiseWithResolve.js.map
|
package/dist/step.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { $$subroutine } from "./constants.js";
|
|
2
2
|
import type { LayerPlan, LayerPlanReasonSubroutine } from "./engine/LayerPlan.js";
|
|
3
3
|
import type { OperationPlan } from "./engine/OperationPlan.js";
|
|
4
|
+
import { inspect } from "./inspect.js";
|
|
4
5
|
import type { AddDependencyOptions, AddUnaryDependencyOptions, DependencyOptions, ExecutionDetails, ExecutionEntryFlags, ExecutionResults, GrafastResultsList, JSONValue, Maybe, PromiseOrDirect, StepOptimizeOptions, UnbatchedExecutionExtra } from "./interfaces.js";
|
|
5
6
|
import type { __FlagStep, __ItemStep } from "./steps/index.js";
|
|
6
7
|
declare function reallyAssertFinalized(plan: Step): void;
|
|
@@ -149,6 +150,7 @@ export declare class Step<TData = any> {
|
|
|
149
150
|
* This metadata will be merged into toString when referencing this plan.
|
|
150
151
|
*/
|
|
151
152
|
toStringMeta(): string | null;
|
|
153
|
+
[inspect.custom](): string;
|
|
152
154
|
planJSONExtra(): Record<string, JSONValue | undefined> | undefined;
|
|
153
155
|
/**
|
|
154
156
|
* **IF IN DOUBT, USE `.addDependency()` INSTEAD!
|
package/dist/step.js
CHANGED
|
@@ -55,7 +55,6 @@ exports.assertFinalized = !dev_js_1.isDev ? dev_js_1.noop : reallyAssertFinalize
|
|
|
55
55
|
* they must be able to execute to return values.
|
|
56
56
|
*/
|
|
57
57
|
class Step {
|
|
58
|
-
static { _a = constants_js_1.$$subroutine, _b = lock_js_1.$$unlock; }
|
|
59
58
|
get dependencyCount() {
|
|
60
59
|
return this.dependencies.length;
|
|
61
60
|
}
|
|
@@ -292,6 +291,9 @@ class Step {
|
|
|
292
291
|
toStringMeta() {
|
|
293
292
|
return null;
|
|
294
293
|
}
|
|
294
|
+
[(_a = constants_js_1.$$subroutine, _b = lock_js_1.$$unlock, inspect_js_1.inspect.custom)]() {
|
|
295
|
+
return this.toString();
|
|
296
|
+
}
|
|
295
297
|
planJSONExtra() {
|
|
296
298
|
return undefined;
|
|
297
299
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { ExecutionDetails, Maybe, PromiseOrDirect } from "
|
|
2
|
-
import { type Deferred } from "../deferred";
|
|
1
|
+
import type { ExecutionDetails, Maybe, PromiseOrDirect } from "../interfaces.js";
|
|
3
2
|
import type { Multistep, UnwrapMultistep } from "../multistep";
|
|
4
3
|
import type { Step } from "../step.js";
|
|
5
4
|
export declare const nextTick: (cb: () => void) => void;
|
|
@@ -9,8 +8,8 @@ export type IOEquivalence<TSpec> = null | string | {
|
|
|
9
8
|
export declare function makeAccessMap<TLookup extends Multistep>($spec: Step, ioEquivalence: IOEquivalence<UnwrapMultistep<TLookup>>): Record<string, Step>;
|
|
10
9
|
export declare function ioEquivalenceMatches(io1: IOEquivalence<Multistep>, io2: IOEquivalence<Multistep>): boolean;
|
|
11
10
|
export declare function paramSig(paramDepIdByKey: Record<string, number>, depIdToStepId: (depId: number) => number): string;
|
|
12
|
-
|
|
13
|
-
deferred:
|
|
11
|
+
interface LoadBatch {
|
|
12
|
+
deferred: PromiseWithResolvers<any>;
|
|
14
13
|
batchSpecs: readonly any[];
|
|
15
14
|
}
|
|
16
15
|
export declare function executeBatches<TLoadInfo extends {
|
|
@@ -6,7 +6,7 @@ exports.ioEquivalenceMatches = ioEquivalenceMatches;
|
|
|
6
6
|
exports.paramSig = paramSig;
|
|
7
7
|
exports.executeBatches = executeBatches;
|
|
8
8
|
exports.executeLoad = executeLoad;
|
|
9
|
-
const
|
|
9
|
+
const dev_js_1 = require("../dev.js");
|
|
10
10
|
const step_js_1 = require("../step.js");
|
|
11
11
|
const utils_js_1 = require("../utils.js");
|
|
12
12
|
const access_js_1 = require("./access.js");
|
|
@@ -151,7 +151,8 @@ function executeLoad(details, sharedDepId, paramDepIdByKey, baseLoadInfo, load)
|
|
|
151
151
|
}
|
|
152
152
|
const pendingCount = batch.size;
|
|
153
153
|
if (pendingCount > 0) {
|
|
154
|
-
const deferred =
|
|
154
|
+
const deferred = Promise.withResolvers();
|
|
155
|
+
deferred.promise.catch(dev_js_1.noop); // Guard against unhandledPromiseRejection
|
|
155
156
|
const batchSpecs = [...batch.keys()];
|
|
156
157
|
const loadBatch = { deferred, batchSpecs };
|
|
157
158
|
if (!meta.loadBatchesByLoad) {
|
|
@@ -174,7 +175,7 @@ function executeLoad(details, sharedDepId, paramDepIdByKey, baseLoadInfo, load)
|
|
|
174
175
|
});
|
|
175
176
|
}
|
|
176
177
|
return (async () => {
|
|
177
|
-
const loadResults = await deferred;
|
|
178
|
+
const loadResults = await deferred.promise;
|
|
178
179
|
for (let pendingIndex = 0; pendingIndex < pendingCount; pendingIndex++) {
|
|
179
180
|
const spec = batchSpecs[pendingIndex];
|
|
180
181
|
const targetIndexes = batch.get(spec);
|
package/dist/steps/connection.js
CHANGED
|
@@ -6,8 +6,8 @@ exports.itemsOrStep = itemsOrStep;
|
|
|
6
6
|
const tslib_1 = require("tslib");
|
|
7
7
|
const iterall_1 = require("iterall");
|
|
8
8
|
const assert = tslib_1.__importStar(require("../assert.js"));
|
|
9
|
-
const deferred_js_1 = require("../deferred.js");
|
|
10
9
|
const withGlobalLayerPlan_js_1 = require("../engine/lib/withGlobalLayerPlan.js");
|
|
10
|
+
const promiseWithResolve_js_1 = require("../promiseWithResolve.js");
|
|
11
11
|
const step_js_1 = require("../step.js");
|
|
12
12
|
const utils_js_1 = require("../utils.js");
|
|
13
13
|
const access_js_1 = require("./access.js");
|
|
@@ -499,8 +499,14 @@ function makeProcessedCollection(mode, collection, params, wrapIndicies) {
|
|
|
499
499
|
items = wrapIndicies ? array.map(indexedItem) : array;
|
|
500
500
|
}
|
|
501
501
|
else {
|
|
502
|
-
|
|
503
|
-
|
|
502
|
+
let resolveHasNext;
|
|
503
|
+
if (typeof __hasMore === "boolean") {
|
|
504
|
+
hasNext = __hasMore;
|
|
505
|
+
}
|
|
506
|
+
else {
|
|
507
|
+
({ promise: hasNext, resolve: resolveHasNext } =
|
|
508
|
+
(0, promiseWithResolve_js_1.promiseWithResolve)());
|
|
509
|
+
}
|
|
504
510
|
let didHaveNext = false;
|
|
505
511
|
let started = false;
|
|
506
512
|
items = (0, utils_js_1.asyncIteratorWithCleanup)((async function* () {
|
|
@@ -556,8 +562,8 @@ function makeProcessedCollection(mode, collection, params, wrapIndicies) {
|
|
|
556
562
|
}
|
|
557
563
|
}
|
|
558
564
|
})(), () => {
|
|
559
|
-
if (
|
|
560
|
-
|
|
565
|
+
if (resolveHasNext !== undefined) {
|
|
566
|
+
resolveHasNext(didHaveNext);
|
|
561
567
|
}
|
|
562
568
|
if (!started) {
|
|
563
569
|
(0, utils_js_1.terminateIterable)(collection);
|
package/dist/steps/object.js
CHANGED
|
@@ -94,10 +94,13 @@ class ObjectStep extends step_js_1.UnbatchedStep {
|
|
|
94
94
|
this.keys,
|
|
95
95
|
tuple,
|
|
96
96
|
);
|
|
97
|
-
const newObj = this.keys.reduce(
|
|
98
|
-
memo
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
const newObj = this.keys.reduce(
|
|
98
|
+
(memo, key, i) => {
|
|
99
|
+
memo[key] = tuple[i];
|
|
100
|
+
return memo;
|
|
101
|
+
},
|
|
102
|
+
Object.create(null) as Partial<DataFromObjectSteps<TPlans>>,
|
|
103
|
+
) as DataFromObjectSteps<TPlans>;
|
|
101
104
|
|
|
102
105
|
// Cache newObj so the same tuple values result in the exact same object.
|
|
103
106
|
meta.results.push([tuple, newObj]);
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { ConstValueNode, DirectiveNode, FieldNode, GraphQLEnumValueConfig, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLInputObjectTypeConfig, GraphQLInputType, GraphQLNamedType, GraphQLObjectTypeConfig, GraphQLSchema, ValueNode } from "graphql";
|
|
2
2
|
import * as graphql from "graphql";
|
|
3
|
-
import type { Deferred } from "./deferred.js";
|
|
4
3
|
import type { LayerPlan, LayerPlanReasonDefer, LayerPlanReasonListItem, LayerPlanReasonSubscription } from "./engine/LayerPlan.js";
|
|
5
4
|
import type { OperationPlan } from "./engine/OperationPlan.js";
|
|
6
5
|
import type { BaseGraphQLArguments, GrafastFieldConfig, GrafastInputFieldConfig, Maybe } from "./interfaces.js";
|
|
@@ -23,10 +22,6 @@ export declare function isPromise<T>(t: T | Promise<T>): t is Promise<T>;
|
|
|
23
22
|
* Is "thenable".
|
|
24
23
|
*/
|
|
25
24
|
export declare function isPromiseLike<T>(t: T | PromiseLike<T>): t is PromiseLike<T>;
|
|
26
|
-
/**
|
|
27
|
-
* Is a promise that can be externally resolved.
|
|
28
|
-
*/
|
|
29
|
-
export declare function isDeferred<T>(t: T | Promise<T> | Deferred<T>): t is Deferred<T>;
|
|
30
25
|
/**
|
|
31
26
|
* Returns true if array1 and array2 have the same length, and every pair of
|
|
32
27
|
* values within them pass the `comparator` check (which defaults to `===`).
|
package/dist/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.assertNullPrototype = assertNullPrototype;
|
|
|
5
5
|
exports.defaultValueToValueNode = defaultValueToValueNode;
|
|
6
6
|
exports.isPromise = isPromise;
|
|
7
7
|
exports.isPromiseLike = isPromiseLike;
|
|
8
|
-
exports.isDeferred = isDeferred;
|
|
9
8
|
exports.arraysMatch = arraysMatch;
|
|
10
9
|
exports.maybeArraysMatch = maybeArraysMatch;
|
|
11
10
|
exports.mapsMatch = mapsMatch;
|
|
@@ -237,14 +236,6 @@ function isPromise(t) {
|
|
|
237
236
|
function isPromiseLike(t) {
|
|
238
237
|
return t != null && typeof t.then === "function";
|
|
239
238
|
}
|
|
240
|
-
/**
|
|
241
|
-
* Is a promise that can be externally resolved.
|
|
242
|
-
*/
|
|
243
|
-
function isDeferred(t) {
|
|
244
|
-
return (isPromise(t) &&
|
|
245
|
-
typeof t.resolve === "function" &&
|
|
246
|
-
typeof t.reject === "function");
|
|
247
|
-
}
|
|
248
239
|
/**
|
|
249
240
|
* Returns true if array1 and array2 have the same length, and every pair of
|
|
250
241
|
* values within them pass the `comparator` check (which defaults to `===`).
|
|
@@ -383,7 +374,7 @@ function objectSpec(spec) {
|
|
|
383
374
|
const modifiedFields = Object.keys(fields).reduce((o, key) => {
|
|
384
375
|
o[key] = objectFieldSpec(fields[key], `${spec.name}.${key}`);
|
|
385
376
|
return o;
|
|
386
|
-
},
|
|
377
|
+
}, Object.create(null));
|
|
387
378
|
return modifiedFields;
|
|
388
379
|
},
|
|
389
380
|
};
|
|
@@ -431,7 +422,7 @@ function objectFieldSpec(grafastSpec, path) {
|
|
|
431
422
|
};
|
|
432
423
|
return memo;
|
|
433
424
|
}, Object.create(null))
|
|
434
|
-
:
|
|
425
|
+
: Object.create(null);
|
|
435
426
|
return {
|
|
436
427
|
...spec,
|
|
437
428
|
args: argsWithExtensions,
|
|
@@ -465,7 +456,7 @@ function inputObjectSpec(spec) {
|
|
|
465
456
|
const modifiedFields = Object.keys(fields).reduce((o, key) => {
|
|
466
457
|
o[key] = inputObjectFieldSpec(fields[key], `${spec.name}.${key}`);
|
|
467
458
|
return o;
|
|
468
|
-
},
|
|
459
|
+
}, Object.create(null));
|
|
469
460
|
return modifiedFields;
|
|
470
461
|
},
|
|
471
462
|
};
|
|
@@ -1141,7 +1132,14 @@ function asyncIteratorWithCleanup(iterable, callback) {
|
|
|
1141
1132
|
}
|
|
1142
1133
|
function terminateIterable(iterable) {
|
|
1143
1134
|
if ("return" in iterable && typeof iterable.return === "function") {
|
|
1144
|
-
|
|
1135
|
+
try {
|
|
1136
|
+
const result = iterable.return();
|
|
1137
|
+
if (isPromiseLike(result))
|
|
1138
|
+
result.then(null, dev_js_1.noop);
|
|
1139
|
+
}
|
|
1140
|
+
catch {
|
|
1141
|
+
/*noop*/
|
|
1142
|
+
}
|
|
1145
1143
|
}
|
|
1146
1144
|
}
|
|
1147
1145
|
exports.GraphQLSpecifiedErrorBehaviors = Object.freeze([
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const version = "1.0.0-rc.
|
|
1
|
+
export declare const version = "1.0.0-rc.4";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grafast",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.4",
|
|
4
4
|
"description": "Cutting edge GraphQL planning and execution engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://grafast.org",
|
|
54
54
|
"engines": {
|
|
55
|
-
"node": ">=
|
|
55
|
+
"node": ">=22"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@graphile/lru": "^5.0.0-rc.
|
|
58
|
+
"@graphile/lru": "^5.0.0-rc.3",
|
|
59
59
|
"chalk": "^4.1.2",
|
|
60
60
|
"debug": "^4.4.3",
|
|
61
61
|
"eventemitter3": "^5.0.1",
|
|
62
|
-
"graphile-config": "^1.0.0-rc.
|
|
62
|
+
"graphile-config": "^1.0.0-rc.3",
|
|
63
63
|
"graphql": "^16.9.0",
|
|
64
64
|
"iterall": "^1.3.0",
|
|
65
65
|
"tslib": "^2.8.1"
|
package/dist/deferred.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A promise that can be `.resolve()`-ed or `.reject()`-ed at a later time.
|
|
3
|
-
*/
|
|
4
|
-
export interface Deferred<T> extends PromiseLike<T> {
|
|
5
|
-
resolve: (input: T | PromiseLike<T>) => void;
|
|
6
|
-
reject: (error: Error) => void;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Returns a promise that can be `.resolve()`-ed or `.reject()`-ed at a later
|
|
10
|
-
* time.
|
|
11
|
-
*/
|
|
12
|
-
export declare function defer<T = void>(): Deferred<T>;
|
|
13
|
-
//# sourceMappingURL=deferred.d.ts.map
|
package/dist/deferred.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defer = defer;
|
|
4
|
-
function NOOP() { }
|
|
5
|
-
/**
|
|
6
|
-
* Returns a promise that can be `.resolve()`-ed or `.reject()`-ed at a later
|
|
7
|
-
* time.
|
|
8
|
-
*/
|
|
9
|
-
function defer() {
|
|
10
|
-
let resolve;
|
|
11
|
-
let reject;
|
|
12
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
13
|
-
resolve = _resolve;
|
|
14
|
-
reject = _reject;
|
|
15
|
-
});
|
|
16
|
-
promise.resolve = resolve;
|
|
17
|
-
promise.reject = reject;
|
|
18
|
-
// PERF: this is to avoid unhandledPromiseRejection errors; generally
|
|
19
|
-
// deferred errors are handled at a later time (or can be safely ignored if
|
|
20
|
-
// another error wins). Maybe there's a better way?
|
|
21
|
-
promise.then(null, NOOP);
|
|
22
|
-
return promise;
|
|
23
|
-
}
|
|
24
|
-
//# sourceMappingURL=deferred.js.map
|