@gqloom/core 0.8.2 → 0.8.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/index.cjs CHANGED
@@ -82,6 +82,7 @@ __export(src_exports, {
82
82
  query: () => query,
83
83
  resolver: () => resolver,
84
84
  resolverPayloadStorage: () => resolverPayloadStorage,
85
+ screamingSnakeCase: () => screamingSnakeCase,
85
86
  silk: () => silk,
86
87
  subscription: () => subscription,
87
88
  toObjMap: () => toObjMap,
@@ -314,6 +315,9 @@ function pascalCase(str) {
314
315
  function capitalize(str) {
315
316
  return str.slice(0, 1).toUpperCase() + str.slice(1);
316
317
  }
318
+ function screamingSnakeCase(str) {
319
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").split(/[\s-_]+/).map((word) => word.toUpperCase()).join("_");
320
+ }
317
321
 
318
322
  // src/utils/error.ts
319
323
  function markErrorLocation(error, ...locations) {
@@ -1148,6 +1152,17 @@ var ObjectChainResolver = class extends ChainResolver {
1148
1152
  // src/schema/object.ts
1149
1153
  var import_graphql5 = require("graphql");
1150
1154
 
1155
+ // src/utils/async-iterator.ts
1156
+ function bindAsyncIterator(storage, generator) {
1157
+ const store = storage.getStore();
1158
+ const next = generator.next;
1159
+ Object.defineProperty(generator, "next", {
1160
+ value: (...args) => storage.run(store, () => next.apply(generator, args)),
1161
+ writable: false
1162
+ });
1163
+ return generator;
1164
+ }
1165
+
1151
1166
  // src/schema/input.ts
1152
1167
  var import_graphql4 = require("graphql");
1153
1168
  function inputToArgs(input, options) {
@@ -1363,10 +1378,10 @@ var LoomObjectType = class _LoomObjectType extends import_graphql5.GraphQLObject
1363
1378
  return {
1364
1379
  subscribe: (root, args, context, info) => resolverPayloadStorage.run(
1365
1380
  { root, args, context, info, field: field2 },
1366
- () => field2["~meta"].subscribe?.(
1367
- args,
1368
- this.resolverOptions
1369
- )
1381
+ async () => {
1382
+ const generator = await field2["~meta"].subscribe?.(args, this.resolverOptions);
1383
+ return bindAsyncIterator(resolverPayloadStorage, generator);
1384
+ }
1370
1385
  )
1371
1386
  };
1372
1387
  }
@@ -1743,6 +1758,7 @@ function ensureInterfaceType(gqlType, interfaceConfig) {
1743
1758
  query,
1744
1759
  resolver,
1745
1760
  resolverPayloadStorage,
1761
+ screamingSnakeCase,
1746
1762
  silk,
1747
1763
  subscription,
1748
1764
  toObjMap,
package/dist/index.d.cts CHANGED
@@ -656,6 +656,7 @@ interface ReadOnlyObjMap<T> {
656
656
 
657
657
  declare function pascalCase(str: string): string;
658
658
  declare function capitalize<T extends string>(str: T): Capitalize<T>;
659
+ declare function screamingSnakeCase(str: string): string;
659
660
 
660
661
  declare function markErrorLocation<TError>(error: TError, ...locations: string[]): TError;
661
662
  declare function tryIn<T>(func: () => T, ...locations: string[]): T;
@@ -870,4 +871,4 @@ interface GQLoomExtensionAttribute {
870
871
  directives?: string[];
871
872
  }
872
873
 
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 };
874
+ 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, screamingSnakeCase, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
package/dist/index.d.ts CHANGED
@@ -656,6 +656,7 @@ interface ReadOnlyObjMap<T> {
656
656
 
657
657
  declare function pascalCase(str: string): string;
658
658
  declare function capitalize<T extends string>(str: T): Capitalize<T>;
659
+ declare function screamingSnakeCase(str: string): string;
659
660
 
660
661
  declare function markErrorLocation<TError>(error: TError, ...locations: string[]): TError;
661
662
  declare function tryIn<T>(func: () => T, ...locations: string[]): T;
@@ -870,4 +871,4 @@ interface GQLoomExtensionAttribute {
870
871
  directives?: string[];
871
872
  }
872
873
 
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 };
874
+ 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, screamingSnakeCase, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
package/dist/index.js CHANGED
@@ -224,6 +224,9 @@ function pascalCase(str) {
224
224
  function capitalize(str) {
225
225
  return str.slice(0, 1).toUpperCase() + str.slice(1);
226
226
  }
227
+ function screamingSnakeCase(str) {
228
+ return str.replace(/([a-z])([A-Z])/g, "$1_$2").split(/[\s-_]+/).map((word) => word.toUpperCase()).join("_");
229
+ }
227
230
 
228
231
  // src/utils/error.ts
229
232
  function markErrorLocation(error, ...locations) {
@@ -1077,6 +1080,17 @@ import {
1077
1080
  resolveObjMapThunk
1078
1081
  } from "graphql";
1079
1082
 
1083
+ // src/utils/async-iterator.ts
1084
+ function bindAsyncIterator(storage, generator) {
1085
+ const store = storage.getStore();
1086
+ const next = generator.next;
1087
+ Object.defineProperty(generator, "next", {
1088
+ value: (...args) => storage.run(store, () => next.apply(generator, args)),
1089
+ writable: false
1090
+ });
1091
+ return generator;
1092
+ }
1093
+
1080
1094
  // src/schema/input.ts
1081
1095
  import {
1082
1096
  GraphQLInputObjectType,
@@ -1302,10 +1316,10 @@ var LoomObjectType = class _LoomObjectType extends GraphQLObjectType {
1302
1316
  return {
1303
1317
  subscribe: (root, args, context, info) => resolverPayloadStorage.run(
1304
1318
  { root, args, context, info, field: field2 },
1305
- () => field2["~meta"].subscribe?.(
1306
- args,
1307
- this.resolverOptions
1308
- )
1319
+ async () => {
1320
+ const generator = await field2["~meta"].subscribe?.(args, this.resolverOptions);
1321
+ return bindAsyncIterator(resolverPayloadStorage, generator);
1322
+ }
1309
1323
  )
1310
1324
  };
1311
1325
  }
@@ -1691,6 +1705,7 @@ export {
1691
1705
  query,
1692
1706
  resolver,
1693
1707
  resolverPayloadStorage,
1708
+ screamingSnakeCase,
1694
1709
  silk,
1695
1710
  subscription,
1696
1711
  toObjMap,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gqloom/core",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "description": "Create GraphQL schema and resolvers with TypeScript.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",