@gqloom/core 0.8.1 → 0.8.3
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/index.cjs +15 -4
- package/dist/index.d.cts +5 -2
- package/dist/index.d.ts +5 -2
- package/dist/index.js +15 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1148,6 +1148,17 @@ var ObjectChainResolver = class extends ChainResolver {
|
|
|
1148
1148
|
// src/schema/object.ts
|
|
1149
1149
|
var import_graphql5 = require("graphql");
|
|
1150
1150
|
|
|
1151
|
+
// src/utils/async-iterator.ts
|
|
1152
|
+
function bindAsyncIterator(storage, generator) {
|
|
1153
|
+
const store = storage.getStore();
|
|
1154
|
+
const next = generator.next;
|
|
1155
|
+
Object.defineProperty(generator, "next", {
|
|
1156
|
+
value: (...args) => storage.run(store, () => next.apply(generator, args)),
|
|
1157
|
+
writable: false
|
|
1158
|
+
});
|
|
1159
|
+
return generator;
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1151
1162
|
// src/schema/input.ts
|
|
1152
1163
|
var import_graphql4 = require("graphql");
|
|
1153
1164
|
function inputToArgs(input, options) {
|
|
@@ -1363,10 +1374,10 @@ var LoomObjectType = class _LoomObjectType extends import_graphql5.GraphQLObject
|
|
|
1363
1374
|
return {
|
|
1364
1375
|
subscribe: (root, args, context, info) => resolverPayloadStorage.run(
|
|
1365
1376
|
{ root, args, context, info, field: field2 },
|
|
1366
|
-
() =>
|
|
1367
|
-
args,
|
|
1368
|
-
|
|
1369
|
-
|
|
1377
|
+
async () => {
|
|
1378
|
+
const generator = await field2["~meta"].subscribe?.(args, this.resolverOptions);
|
|
1379
|
+
return bindAsyncIterator(resolverPayloadStorage, generator);
|
|
1380
|
+
}
|
|
1370
1381
|
)
|
|
1371
1382
|
};
|
|
1372
1383
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -185,11 +185,14 @@ declare class SubscriptionChainFactory<TOutput extends GraphQLSilk = never, TInp
|
|
|
185
185
|
protected clone(options?: Partial<ChainFactoryOptions>): this;
|
|
186
186
|
output<TOutputNew extends GraphQLSilk>(output: TOutputNew): SubscriptionChainFactory<TOutputNew, TInput>;
|
|
187
187
|
input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): SubscriptionChainFactory<TOutput, TInputNew>;
|
|
188
|
-
subscribe<TValue = StandardSchemaV1.InferOutput<TOutput>>(subscribe: (input: InferInputO<TInput>) => MayPromise<AsyncIterator<TValue>>): ResolvableSubscription<TOutput, TInput, TValue>;
|
|
188
|
+
subscribe<TValue = StandardSchemaV1.InferOutput<TOutput>>(subscribe: (input: InferInputO<TInput>) => MayPromise<AsyncIterator<TValue>>): TValue extends StandardSchemaV1.InferOutput<TOutput> ? ResolvableSubscription<TOutput, TInput, TValue> : SubscriptionNeedResolve<TOutput, TInput, TValue>;
|
|
189
189
|
}
|
|
190
190
|
interface ResolvableSubscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends Subscription<TOutput, TInput, TValue> {
|
|
191
191
|
resolve(resolve: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Subscription<TOutput, TInput, TValue>;
|
|
192
192
|
}
|
|
193
|
+
interface SubscriptionNeedResolve<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> {
|
|
194
|
+
resolve(resolve: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Subscription<TOutput, TInput, TValue>;
|
|
195
|
+
}
|
|
193
196
|
declare class QueryFactoryWithResolve<TInputO, TOutput extends GraphQLSilk, TInput extends GraphQLSilk<TInputO>> extends BaseChainFactory<Query<TOutput, TInput>> implements Query<TOutput, TInput> {
|
|
194
197
|
protected output: TOutput;
|
|
195
198
|
protected readonly options: QueryOptions<TOutput, TInput>;
|
|
@@ -867,4 +870,4 @@ interface GQLoomExtensionAttribute {
|
|
|
867
870
|
directives?: string[];
|
|
868
871
|
}
|
|
869
872
|
|
|
870
|
-
export { BaseChainFactory, type BaseField, type BatchLoadFn, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, type ChainFactoryOptions, ChainResolver, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, type Field, FieldChainFactory, type FieldConvertOptions, type FieldFactory, FieldFactoryWithResolve, type FieldFactoryWithUtils, type FieldMeta, type FieldOptions, type FieldOrOperation, type FieldOrOperationType, type GQLoomExtensionAttribute, type GQLoomExtensions, type GlobalWeaverContext, type GraphQLFieldOptions, GraphQLSchemaLoom, type GraphQLSilk, type IChainFactory, type InferFieldInput, type InferFieldOutput, type InferInputI, type InferInputO, type IsAny, type ListSilk, typesLoom as Loom, LoomObjectType, type MayPromise, type Middleware, type MiddlewareOptions, type Mutation, MutationChainFactory, type MutationFactory, type MutationFactoryWithChain, MutationFactoryWithResolve, type MutationOptions, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, type OmitInUnion, type OnlyMemoizationPayload, type Operation, type OperationType, type Query, QueryChainFactory, type QueryFactory, type QueryFactoryWithChain, QueryFactoryWithResolve, type QueryOptions, type ResolvableSubscription, type Resolver, type ResolverFactory, type ResolverOptions, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaWeaver, StandardSchemaV1, type Subscription, SubscriptionChainFactory, type SubscriptionFactory, type SubscriptionFactoryWithChain, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, applyMiddlewares, capitalize, collectName, collectNames, compose, createField, createInputParser, createMemoization, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseSilk, pascalCase, provideWeaverContext, query, resolver, resolverPayloadStorage, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
|
|
873
|
+
export { BaseChainFactory, type BaseField, type BatchLoadFn, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, type ChainFactoryOptions, ChainResolver, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, type Field, FieldChainFactory, type FieldConvertOptions, type FieldFactory, FieldFactoryWithResolve, type FieldFactoryWithUtils, type FieldMeta, type FieldOptions, type FieldOrOperation, type FieldOrOperationType, type GQLoomExtensionAttribute, type GQLoomExtensions, type GlobalWeaverContext, type GraphQLFieldOptions, GraphQLSchemaLoom, type GraphQLSilk, type IChainFactory, type InferFieldInput, type InferFieldOutput, type InferInputI, type InferInputO, type IsAny, type ListSilk, typesLoom as Loom, LoomObjectType, type MayPromise, type Middleware, type MiddlewareOptions, type Mutation, MutationChainFactory, type MutationFactory, type MutationFactoryWithChain, MutationFactoryWithResolve, type MutationOptions, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, type OmitInUnion, type OnlyMemoizationPayload, type Operation, type OperationType, type Query, QueryChainFactory, type QueryFactory, type QueryFactoryWithChain, QueryFactoryWithResolve, type QueryOptions, type ResolvableSubscription, type Resolver, type ResolverFactory, type ResolverOptions, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaWeaver, StandardSchemaV1, type Subscription, SubscriptionChainFactory, type SubscriptionFactory, type SubscriptionFactoryWithChain, type SubscriptionNeedResolve, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, applyMiddlewares, capitalize, collectName, collectNames, compose, createField, createInputParser, createMemoization, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseSilk, pascalCase, provideWeaverContext, query, resolver, resolverPayloadStorage, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
|
package/dist/index.d.ts
CHANGED
|
@@ -185,11 +185,14 @@ declare class SubscriptionChainFactory<TOutput extends GraphQLSilk = never, TInp
|
|
|
185
185
|
protected clone(options?: Partial<ChainFactoryOptions>): this;
|
|
186
186
|
output<TOutputNew extends GraphQLSilk>(output: TOutputNew): SubscriptionChainFactory<TOutputNew, TInput>;
|
|
187
187
|
input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): SubscriptionChainFactory<TOutput, TInputNew>;
|
|
188
|
-
subscribe<TValue = StandardSchemaV1.InferOutput<TOutput>>(subscribe: (input: InferInputO<TInput>) => MayPromise<AsyncIterator<TValue>>): ResolvableSubscription<TOutput, TInput, TValue>;
|
|
188
|
+
subscribe<TValue = StandardSchemaV1.InferOutput<TOutput>>(subscribe: (input: InferInputO<TInput>) => MayPromise<AsyncIterator<TValue>>): TValue extends StandardSchemaV1.InferOutput<TOutput> ? ResolvableSubscription<TOutput, TInput, TValue> : SubscriptionNeedResolve<TOutput, TInput, TValue>;
|
|
189
189
|
}
|
|
190
190
|
interface ResolvableSubscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends Subscription<TOutput, TInput, TValue> {
|
|
191
191
|
resolve(resolve: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Subscription<TOutput, TInput, TValue>;
|
|
192
192
|
}
|
|
193
|
+
interface SubscriptionNeedResolve<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> {
|
|
194
|
+
resolve(resolve: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Subscription<TOutput, TInput, TValue>;
|
|
195
|
+
}
|
|
193
196
|
declare class QueryFactoryWithResolve<TInputO, TOutput extends GraphQLSilk, TInput extends GraphQLSilk<TInputO>> extends BaseChainFactory<Query<TOutput, TInput>> implements Query<TOutput, TInput> {
|
|
194
197
|
protected output: TOutput;
|
|
195
198
|
protected readonly options: QueryOptions<TOutput, TInput>;
|
|
@@ -867,4 +870,4 @@ interface GQLoomExtensionAttribute {
|
|
|
867
870
|
directives?: string[];
|
|
868
871
|
}
|
|
869
872
|
|
|
870
|
-
export { BaseChainFactory, type BaseField, type BatchLoadFn, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, type ChainFactoryOptions, ChainResolver, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, type Field, FieldChainFactory, type FieldConvertOptions, type FieldFactory, FieldFactoryWithResolve, type FieldFactoryWithUtils, type FieldMeta, type FieldOptions, type FieldOrOperation, type FieldOrOperationType, type GQLoomExtensionAttribute, type GQLoomExtensions, type GlobalWeaverContext, type GraphQLFieldOptions, GraphQLSchemaLoom, type GraphQLSilk, type IChainFactory, type InferFieldInput, type InferFieldOutput, type InferInputI, type InferInputO, type IsAny, type ListSilk, typesLoom as Loom, LoomObjectType, type MayPromise, type Middleware, type MiddlewareOptions, type Mutation, MutationChainFactory, type MutationFactory, type MutationFactoryWithChain, MutationFactoryWithResolve, type MutationOptions, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, type OmitInUnion, type OnlyMemoizationPayload, type Operation, type OperationType, type Query, QueryChainFactory, type QueryFactory, type QueryFactoryWithChain, QueryFactoryWithResolve, type QueryOptions, type ResolvableSubscription, type Resolver, type ResolverFactory, type ResolverOptions, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaWeaver, StandardSchemaV1, type Subscription, SubscriptionChainFactory, type SubscriptionFactory, type SubscriptionFactoryWithChain, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, applyMiddlewares, capitalize, collectName, collectNames, compose, createField, createInputParser, createMemoization, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseSilk, pascalCase, provideWeaverContext, query, resolver, resolverPayloadStorage, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
|
|
873
|
+
export { BaseChainFactory, type BaseField, type BatchLoadFn, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, type ChainFactoryOptions, ChainResolver, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, type Field, FieldChainFactory, type FieldConvertOptions, type FieldFactory, FieldFactoryWithResolve, type FieldFactoryWithUtils, type FieldMeta, type FieldOptions, type FieldOrOperation, type FieldOrOperationType, type GQLoomExtensionAttribute, type GQLoomExtensions, type GlobalWeaverContext, type GraphQLFieldOptions, GraphQLSchemaLoom, type GraphQLSilk, type IChainFactory, type InferFieldInput, type InferFieldOutput, type InferInputI, type InferInputO, type IsAny, type ListSilk, typesLoom as Loom, LoomObjectType, type MayPromise, type Middleware, type MiddlewareOptions, type Mutation, MutationChainFactory, type MutationFactory, type MutationFactoryWithChain, MutationFactoryWithResolve, type MutationOptions, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, type OmitInUnion, type OnlyMemoizationPayload, type Operation, type OperationType, type Query, QueryChainFactory, type QueryFactory, type QueryFactoryWithChain, QueryFactoryWithResolve, type QueryOptions, type ResolvableSubscription, type Resolver, type ResolverFactory, type ResolverOptions, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaWeaver, StandardSchemaV1, type Subscription, SubscriptionChainFactory, type SubscriptionFactory, type SubscriptionFactoryWithChain, type SubscriptionNeedResolve, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, applyMiddlewares, capitalize, collectName, collectNames, compose, createField, createInputParser, createMemoization, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseSilk, pascalCase, provideWeaverContext, query, resolver, resolverPayloadStorage, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
|
package/dist/index.js
CHANGED
|
@@ -1077,6 +1077,17 @@ import {
|
|
|
1077
1077
|
resolveObjMapThunk
|
|
1078
1078
|
} from "graphql";
|
|
1079
1079
|
|
|
1080
|
+
// src/utils/async-iterator.ts
|
|
1081
|
+
function bindAsyncIterator(storage, generator) {
|
|
1082
|
+
const store = storage.getStore();
|
|
1083
|
+
const next = generator.next;
|
|
1084
|
+
Object.defineProperty(generator, "next", {
|
|
1085
|
+
value: (...args) => storage.run(store, () => next.apply(generator, args)),
|
|
1086
|
+
writable: false
|
|
1087
|
+
});
|
|
1088
|
+
return generator;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1080
1091
|
// src/schema/input.ts
|
|
1081
1092
|
import {
|
|
1082
1093
|
GraphQLInputObjectType,
|
|
@@ -1302,10 +1313,10 @@ var LoomObjectType = class _LoomObjectType extends GraphQLObjectType {
|
|
|
1302
1313
|
return {
|
|
1303
1314
|
subscribe: (root, args, context, info) => resolverPayloadStorage.run(
|
|
1304
1315
|
{ root, args, context, info, field: field2 },
|
|
1305
|
-
() =>
|
|
1306
|
-
args,
|
|
1307
|
-
|
|
1308
|
-
|
|
1316
|
+
async () => {
|
|
1317
|
+
const generator = await field2["~meta"].subscribe?.(args, this.resolverOptions);
|
|
1318
|
+
return bindAsyncIterator(resolverPayloadStorage, generator);
|
|
1319
|
+
}
|
|
1309
1320
|
)
|
|
1310
1321
|
};
|
|
1311
1322
|
}
|