@gqloom/core 0.5.0 → 0.7.0
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/README.md +19 -16
- package/dist/index.cjs +399 -57
- package/dist/index.d.cts +142 -25
- package/dist/index.d.ts +142 -25
- package/dist/index.js +390 -56
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import * as graphql from 'graphql';
|
|
1
2
|
import { GraphQLOutputType, GraphQLObjectTypeConfig, GraphQLFieldConfig, GraphQLResolveInfo, GraphQLScalarType, GraphQLObjectType, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLSchemaConfig, GraphQLFieldMap, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
|
|
3
|
+
import * as graphql_jsutils_Maybe from 'graphql/jsutils/Maybe';
|
|
2
4
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
3
5
|
|
|
4
6
|
/**
|
|
@@ -195,6 +197,70 @@ declare function getStandardValue<T>(result: StandardSchemaV1.Result<T>): T;
|
|
|
195
197
|
declare function getStandardValue<T>(result?: StandardSchemaV1.Result<T>): T | undefined;
|
|
196
198
|
declare function getStandardValue<T>(result: StandardSchemaV1.Result<T> | null): T | null;
|
|
197
199
|
|
|
200
|
+
interface IChainFactory<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined> {
|
|
201
|
+
description(description: GraphQLFieldOptions["description"]): this;
|
|
202
|
+
deprecationReason(deprecationReason: GraphQLFieldOptions["deprecationReason"]): this;
|
|
203
|
+
extensions(extensions: GraphQLFieldOptions["extensions"]): this;
|
|
204
|
+
output<TOutputNew extends TSchemaIO[0]>(output: TOutputNew): IChainFactory<TSchemaIO, TOutputNew, TInput>;
|
|
205
|
+
input<TInputNew extends InputSchema<TSchemaIO[0]>>(input: TInputNew): IChainFactory<TSchemaIO, TOutput, TInputNew>;
|
|
206
|
+
}
|
|
207
|
+
declare abstract class BaseChainFactory {
|
|
208
|
+
protected readonly options?: Partial<FieldOrOperation<any, any, any, any> & {
|
|
209
|
+
middlewares: Middleware[];
|
|
210
|
+
}> | undefined;
|
|
211
|
+
static methods(): {
|
|
212
|
+
description: (description: graphql_jsutils_Maybe.Maybe<string>) => BaseChainFactory;
|
|
213
|
+
deprecationReason: (deprecationReason: graphql_jsutils_Maybe.Maybe<string>) => BaseChainFactory;
|
|
214
|
+
extensions: (extensions: graphql_jsutils_Maybe.Maybe<Readonly<graphql.GraphQLFieldExtensions<any, any, any>>>) => BaseChainFactory;
|
|
215
|
+
};
|
|
216
|
+
constructor(options?: Partial<FieldOrOperation<any, any, any, any> & {
|
|
217
|
+
middlewares: Middleware[];
|
|
218
|
+
}> | undefined);
|
|
219
|
+
protected abstract clone(options?: Partial<FieldOrOperation<any, any, any, any> & {
|
|
220
|
+
middlewares: Middleware[];
|
|
221
|
+
}>): this;
|
|
222
|
+
description(description: GraphQLFieldOptions["description"]): this;
|
|
223
|
+
deprecationReason(deprecationReason: GraphQLFieldOptions["deprecationReason"]): this;
|
|
224
|
+
extensions(extensions: GraphQLFieldOptions["extensions"]): this;
|
|
225
|
+
use(...middlewares: Middleware[]): this;
|
|
226
|
+
}
|
|
227
|
+
declare class FieldChainFactory<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0] = never, TInput extends InputSchema<TSchemaIO[0]> = undefined> extends BaseChainFactory implements IChainFactory<TSchemaIO, TOutput, TInput> {
|
|
228
|
+
static methods(): FieldChainFactory<any, never, undefined>;
|
|
229
|
+
protected clone(options?: Partial<FieldOrOperation<any, any, any, any>>): this;
|
|
230
|
+
use(...middlewares: Middleware<FieldOrOperation<any, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "field">>[]): this;
|
|
231
|
+
output<TOutputNew extends TSchemaIO[0]>(output: TOutputNew): FieldChainFactory<TSchemaIO, TOutputNew, TInput>;
|
|
232
|
+
input<TInputNew extends InputSchema<TSchemaIO[0]>>(input: TInputNew): FieldChainFactory<TSchemaIO, TOutput, TInputNew>;
|
|
233
|
+
resolve<TParent extends TSchemaIO[0]>(resolve: (parent: InferSchemaO<TParent, TSchemaIO>, input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>): FieldOrOperation<SchemaToSilk<TSchemaIO, TParent>, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "field">;
|
|
234
|
+
}
|
|
235
|
+
declare class QueryChainFactory<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0] = never, TInput extends InputSchema<TSchemaIO[0]> = undefined> extends BaseChainFactory implements IChainFactory<TSchemaIO, TOutput, TInput> {
|
|
236
|
+
static methods(): QueryChainFactory<any, never, undefined>;
|
|
237
|
+
protected clone(options?: Partial<FieldOrOperation<any, any, any, any>>): this;
|
|
238
|
+
use(...middlewares: Middleware<FieldOrOperation<any, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "query">>[]): this;
|
|
239
|
+
output<TOutputNew extends TSchemaIO[0]>(output: TOutputNew): QueryChainFactory<TSchemaIO, TOutputNew, TInput>;
|
|
240
|
+
input<TInputNew extends InputSchema<TSchemaIO[0]>>(input: TInputNew): QueryChainFactory<TSchemaIO, TOutput, TInputNew>;
|
|
241
|
+
resolve(resolve: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>): any;
|
|
242
|
+
}
|
|
243
|
+
declare class MutationChainFactory<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0] = never, TInput extends InputSchema<TSchemaIO[0]> = undefined> extends BaseChainFactory implements IChainFactory<TSchemaIO, TOutput, TInput> {
|
|
244
|
+
static methods(): MutationChainFactory<any, never, undefined>;
|
|
245
|
+
protected clone(options?: Partial<FieldOrOperation<any, any, any, any>>): this;
|
|
246
|
+
use(...middlewares: Middleware<FieldOrOperation<any, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "mutation">>[]): this;
|
|
247
|
+
output<TOutputNew extends TSchemaIO[0]>(output: TOutputNew): MutationChainFactory<TSchemaIO, TOutputNew, TInput>;
|
|
248
|
+
input<TInputNew extends InputSchema<TSchemaIO[0]>>(input: TInputNew): MutationChainFactory<TSchemaIO, TOutput, TInputNew>;
|
|
249
|
+
resolve(resolve: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>): any;
|
|
250
|
+
}
|
|
251
|
+
declare class SubscriptionChainFactory<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0] = never, TInput extends InputSchema<TSchemaIO[0]> = undefined> extends BaseChainFactory implements IChainFactory<TSchemaIO, TOutput, TInput> {
|
|
252
|
+
static methods(): SubscriptionChainFactory<any, never, undefined>;
|
|
253
|
+
protected clone(options?: Partial<FieldOrOperation<any, any, any, any>>): this;
|
|
254
|
+
use(...middlewares: Middleware<FieldOrOperation<any, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "subscription">>[]): this;
|
|
255
|
+
output<TOutputNew extends TSchemaIO[0]>(output: TOutputNew): SubscriptionChainFactory<TSchemaIO, TOutputNew, TInput>;
|
|
256
|
+
input<TInputNew extends InputSchema<TSchemaIO[0]>>(input: TInputNew): SubscriptionChainFactory<TSchemaIO, TOutput, TInputNew>;
|
|
257
|
+
subscribe<TValue = InferSchemaO<TOutput, TSchemaIO>>(subscribe: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<AsyncIterator<TValue>>): ResolvableSubscription<TSchemaIO, TOutput, TInput, TValue>;
|
|
258
|
+
}
|
|
259
|
+
interface ResolvableSubscription<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined, TValue = InferSchemaO<TOutput, TSchemaIO>> extends Subscription<SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, TValue> {
|
|
260
|
+
resolve(resolve: (value: TValue, input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>): Subscription<SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, TValue>;
|
|
261
|
+
resolve(value: TValue, input: any): MayPromise<any>;
|
|
262
|
+
}
|
|
263
|
+
|
|
198
264
|
interface GraphQLSilk<TOutput = any, TInput = any> extends StandardSchemaV1<TInput, TOutput> {
|
|
199
265
|
/**
|
|
200
266
|
* GraphQL type for schema
|
|
@@ -254,12 +320,21 @@ interface QueryMutationOptions<TSchemaIO extends AbstractSchemaIO, TOutput exten
|
|
|
254
320
|
*/
|
|
255
321
|
interface QueryFactory<TSchemaIO extends AbstractSchemaIO> {
|
|
256
322
|
<TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined>(output: TOutput, resolveOrOptions: (() => MayPromise<InferSchemaO<TOutput, TSchemaIO>>) | QueryMutationOptions<TSchemaIO, TOutput, TInput>): FieldOrOperation<undefined, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "query">;
|
|
323
|
+
<TOutput extends TSchemaIO[0]>(output: TOutput): QueryChainFactory<TSchemaIO, TOutput, undefined>;
|
|
324
|
+
}
|
|
325
|
+
interface QueryFactoryWithChain<TSchemaIO extends AbstractSchemaIO> extends QueryFactory<TSchemaIO>, QueryChainFactory<TSchemaIO, never, undefined> {
|
|
257
326
|
}
|
|
258
327
|
/**
|
|
259
328
|
* Function to create a GraphQL mutation.
|
|
260
329
|
*/
|
|
261
330
|
interface MutationFactory<TSchemaIO extends AbstractSchemaIO> {
|
|
262
331
|
<TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined>(output: TOutput, resolveOrOptions: (() => MayPromise<InferSchemaO<TOutput, TSchemaIO>>) | QueryMutationOptions<TSchemaIO, TOutput, TInput>): FieldOrOperation<undefined, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "mutation">;
|
|
332
|
+
<TOutput extends TSchemaIO[0]>(output: TOutput): MutationChainFactory<TSchemaIO, TOutput, undefined>;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Function to create a GraphQL mutation.
|
|
336
|
+
*/
|
|
337
|
+
interface MutationFactoryWithChain<TSchemaIO extends AbstractSchemaIO> extends MutationFactory<TSchemaIO>, MutationChainFactory<TSchemaIO, never, undefined> {
|
|
263
338
|
}
|
|
264
339
|
/**
|
|
265
340
|
* Options for External Filed of existing GraphQL Object.
|
|
@@ -273,8 +348,9 @@ interface FieldOptions<TSchemaIO extends AbstractSchemaIO, TParent extends TSche
|
|
|
273
348
|
*/
|
|
274
349
|
interface FieldFactory<TSchemaIO extends AbstractSchemaIO> {
|
|
275
350
|
<TParent extends TSchemaIO[0], TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined>(output: TOutput, resolveOrOptions: ((parent: InferSchemaO<TParent, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>) | FieldOptions<TSchemaIO, TParent, TOutput, TInput>): FieldOrOperation<SchemaToSilk<TSchemaIO, TParent>, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "field">;
|
|
351
|
+
<TOutput extends TSchemaIO[0]>(output: TOutput): FieldChainFactory<TSchemaIO, TOutput, undefined>;
|
|
276
352
|
}
|
|
277
|
-
interface FieldFactoryWithUtils<TSchemaIO extends AbstractSchemaIO> extends FieldFactory<TSchemaIO> {
|
|
353
|
+
interface FieldFactoryWithUtils<TSchemaIO extends AbstractSchemaIO> extends FieldFactory<TSchemaIO>, FieldChainFactory<TSchemaIO, never, undefined> {
|
|
278
354
|
/** Set fields to be hidden in GraphQL Schema */
|
|
279
355
|
hidden: typeof FIELD_HIDDEN;
|
|
280
356
|
}
|
|
@@ -295,6 +371,9 @@ interface Subscription<TOutput extends GraphQLSilk, TInput extends InputSchema<G
|
|
|
295
371
|
*/
|
|
296
372
|
interface SubscriptionFactory<TSchemaIO extends AbstractSchemaIO> {
|
|
297
373
|
<TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined, TValue = InferSchemaO<TOutput, TSchemaIO>>(output: TOutput, subscribeOrOptions: (() => MayPromise<AsyncIterator<InferSchemaO<TOutput, TSchemaIO>>>) | SubscriptionOptions<TSchemaIO, TOutput, TInput, TValue>): Subscription<SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, TValue>;
|
|
374
|
+
<TOutput extends TSchemaIO[0]>(output: TOutput): SubscriptionChainFactory<TSchemaIO, TOutput, undefined>;
|
|
375
|
+
}
|
|
376
|
+
interface SubscriptionFactoryWithChain<TSchemaIO extends AbstractSchemaIO> extends SubscriptionFactory<TSchemaIO>, SubscriptionChainFactory<TSchemaIO, never, undefined> {
|
|
298
377
|
}
|
|
299
378
|
interface ResolverFactory<TSchemaIO extends AbstractSchemaIO> {
|
|
300
379
|
of<TParent extends TSchemaIO[0], TOperations extends Record<string, FieldOrOperation<SchemaToSilk<TSchemaIO, TParent>, any, any> | FieldOrOperation<undefined, any, any, OperationType> | typeof FIELD_HIDDEN>>(parent: TParent, operationOrFields: TOperations, options?: ResolverOptionsWithExtensions<OmitInUnion<ValueOf<TOperations>, typeof FIELD_HIDDEN>>): TOperations;
|
|
@@ -450,6 +529,9 @@ interface ReadOnlyObjMap<T> {
|
|
|
450
529
|
readonly [key: string]: T;
|
|
451
530
|
}
|
|
452
531
|
|
|
532
|
+
declare function pascalCase(str: string): string;
|
|
533
|
+
declare function capitalize<T extends string>(str: T): Capitalize<T>;
|
|
534
|
+
|
|
453
535
|
declare function markErrorLocation<TError>(error: TError, ...locations: string[]): TError;
|
|
454
536
|
declare function tryIn<T>(func: () => T, ...locations: string[]): T;
|
|
455
537
|
/**
|
|
@@ -464,6 +546,25 @@ declare function tryIn<T>(func: () => T, ...locations: string[]): T;
|
|
|
464
546
|
*/
|
|
465
547
|
declare function markLocation(message: string, ...locations: string[]): string;
|
|
466
548
|
|
|
549
|
+
type BatchLoadFn<TKey, TData> = (keys: TKey[]) => Promise<(TData | Error)[]>;
|
|
550
|
+
declare class EasyDataLoader<TKey, TData> {
|
|
551
|
+
protected readonly batchLoadFn: BatchLoadFn<TKey, TData>;
|
|
552
|
+
protected queue: TKey[];
|
|
553
|
+
protected cache: Map<TKey, Promise<TData>>;
|
|
554
|
+
protected resolvers: Map<TKey, [
|
|
555
|
+
resolve: (value: TData | PromiseLike<TData>) => void,
|
|
556
|
+
reject: (reason?: any) => void
|
|
557
|
+
]>;
|
|
558
|
+
constructor(batchLoadFn: BatchLoadFn<TKey, TData>);
|
|
559
|
+
load(key: TKey): Promise<TData>;
|
|
560
|
+
clear(): void;
|
|
561
|
+
clearByKey(key: TKey): void;
|
|
562
|
+
protected executeBatchLoad(): Promise<void>;
|
|
563
|
+
protected nextTickPromise?: Promise<void>;
|
|
564
|
+
protected nextTickBatchLoad(): Promise<void>;
|
|
565
|
+
static nextTick(): Promise<void>;
|
|
566
|
+
}
|
|
567
|
+
|
|
467
568
|
/**
|
|
468
569
|
* Create a Silk from Scalar.
|
|
469
570
|
*/
|
|
@@ -512,20 +613,24 @@ type InferScalarInternal<T extends GraphQLScalarType> = T extends GraphQLScalarT
|
|
|
512
613
|
type InferScalarExternal<T extends GraphQLScalarType> = T extends GraphQLScalarType<any, infer TExternal> ? TExternal : never;
|
|
513
614
|
type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
|
|
514
615
|
|
|
515
|
-
declare const
|
|
516
|
-
declare const
|
|
616
|
+
declare const createQuery: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => MayPromise<unknown>) | QueryMutationOptions<GraphQLSilkIO, any, any>) => QueryChainFactory<AbstractSchemaIO, never, undefined> | FieldOrOperation<any, any, any, "query">;
|
|
617
|
+
declare const query: QueryFactoryWithChain<GraphQLSilkIO>;
|
|
618
|
+
declare const createMutation: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => MayPromise<unknown>) | QueryMutationOptions<GraphQLSilkIO, any, any>) => MutationChainFactory<AbstractSchemaIO, never, undefined> | FieldOrOperation<any, any, any, "mutation">;
|
|
619
|
+
declare const mutation: MutationFactoryWithChain<GraphQLSilkIO>;
|
|
620
|
+
declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: FieldOptions<GraphQLSilkIO, any, any, any> | ((parent: unknown) => unknown) | undefined) => FieldChainFactory<AbstractSchemaIO, never, undefined> | FieldOrOperation<any, any, any, "field">;
|
|
517
621
|
declare const field: FieldFactoryWithUtils<GraphQLSilkIO>;
|
|
518
622
|
declare const defaultSubscriptionResolve: (source: any) => any;
|
|
519
|
-
declare const
|
|
623
|
+
declare const createSubscription: (output: GraphQLSilk<any, any>, subscribeOrOptions?: (() => MayPromise<AsyncIterator<unknown>>) | SubscriptionOptions<GraphQLSilkIO, any, any, any>) => Subscription<any, any, any> | SubscriptionChainFactory<AbstractSchemaIO, never, undefined>;
|
|
624
|
+
declare const subscription: SubscriptionFactoryWithChain<GraphQLSilkIO>;
|
|
520
625
|
declare const ResolverOptionsMap: WeakMap<object, ResolverOptionsWithParent<GenericFieldOrOperation>>;
|
|
521
626
|
declare function baseResolver(operations: Record<string, FieldOrOperation<any, any, any>>, options: ResolverOptionsWithParent | undefined): Record<string, FieldOrOperation<any, any, any, FieldOrOperationType>>;
|
|
522
627
|
declare const resolver: ResolverFactory<GraphQLSilkIO>;
|
|
523
628
|
declare const loom: {
|
|
524
|
-
query:
|
|
629
|
+
query: QueryFactoryWithChain<GraphQLSilkIO>;
|
|
525
630
|
resolver: ResolverFactory<GraphQLSilkIO>;
|
|
526
631
|
field: FieldFactoryWithUtils<GraphQLSilkIO>;
|
|
527
|
-
subscription:
|
|
528
|
-
mutation:
|
|
632
|
+
subscription: SubscriptionFactoryWithChain<GraphQLSilkIO>;
|
|
633
|
+
mutation: MutationFactoryWithChain<GraphQLSilkIO>;
|
|
529
634
|
};
|
|
530
635
|
|
|
531
636
|
declare function createResolverFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk): ResolverFactory<TSchemaIO>;
|
|
@@ -541,11 +646,11 @@ declare function createLoom<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema:
|
|
|
541
646
|
subscription: SubscriptionFactory<TSchemaIO>;
|
|
542
647
|
};
|
|
543
648
|
|
|
544
|
-
interface
|
|
649
|
+
interface SchemaWeaver {
|
|
545
650
|
vendor: string;
|
|
546
651
|
getGraphQLType: (schema: any) => GraphQLOutputType;
|
|
547
652
|
}
|
|
548
|
-
declare function isSchemaVendorWeaver(some: any): some is
|
|
653
|
+
declare function isSchemaVendorWeaver(some: any): some is SchemaWeaver;
|
|
549
654
|
|
|
550
655
|
interface WeaverContext {
|
|
551
656
|
id: number;
|
|
@@ -561,11 +666,11 @@ interface WeaverContext {
|
|
|
561
666
|
memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
|
|
562
667
|
getNamedType<T extends GraphQLOutputType>(name: string): T | undefined;
|
|
563
668
|
names: WeakMap<object, string>;
|
|
564
|
-
vendorWeavers: Map<string,
|
|
669
|
+
vendorWeavers: Map<string, SchemaWeaver>;
|
|
565
670
|
}
|
|
566
671
|
interface WeaverConfig {
|
|
567
672
|
[WEAVER_CONFIG]: string | symbol;
|
|
568
|
-
vendorWeaver?:
|
|
673
|
+
vendorWeaver?: SchemaWeaver;
|
|
569
674
|
}
|
|
570
675
|
declare function initWeaverContext(): WeaverContext;
|
|
571
676
|
declare namespace initWeaverContext {
|
|
@@ -615,35 +720,44 @@ interface CoreSchemaWeaverConfig extends WeaverConfig, CoreSchemaWeaverConfigOpt
|
|
|
615
720
|
declare class LoomObjectType extends GraphQLObjectType {
|
|
616
721
|
protected extraFields: Map<string, SilkFieldOrOperation>;
|
|
617
722
|
protected hiddenFields: Set<string>;
|
|
723
|
+
static AUTO_ALIASING: "__gqloom_auto_aliasing";
|
|
618
724
|
protected weaverContext: WeaverContext;
|
|
619
725
|
protected resolverOptions?: ResolvingOptions;
|
|
620
726
|
constructor(objectOrGetter: string | GraphQLObjectType | GraphQLObjectTypeConfig<any, any> | (() => GraphQLObjectType | GraphQLObjectTypeConfig<any, any>), options?: {
|
|
621
727
|
weaverContext?: WeaverContext;
|
|
622
728
|
resolverOptions?: ResolvingOptions;
|
|
623
729
|
});
|
|
730
|
+
protected hasExplicitName?: boolean;
|
|
731
|
+
protected _aliases: string[];
|
|
732
|
+
get aliases(): string[];
|
|
733
|
+
addAlias(name: string): void;
|
|
734
|
+
protected renameByAliases(): void;
|
|
624
735
|
hideField(name: string): void;
|
|
625
736
|
addField(name: string, resolver: SilkFieldOrOperation): void;
|
|
626
737
|
mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
|
|
627
738
|
private extraFieldMap?;
|
|
628
739
|
getFields(): GraphQLFieldMap<any, any>;
|
|
629
740
|
protected mapToFieldConfig(map: Map<string, SilkFieldOrOperation>): Record<string, GraphQLFieldConfig<any, any>>;
|
|
630
|
-
toFieldConfig(field: SilkFieldOrOperation): GraphQLFieldConfig<any, any>;
|
|
741
|
+
toFieldConfig(field: SilkFieldOrOperation, fieldName?: string): GraphQLFieldConfig<any, any>;
|
|
631
742
|
protected provideForResolve(field: SilkFieldOrOperation): Pick<GraphQLFieldConfig<any, any>, "resolve"> | undefined;
|
|
632
743
|
protected provideForSubscribe(field: SilkFieldOrOperation): Pick<GraphQLFieldConfig<any, any>, "subscribe"> | undefined;
|
|
633
|
-
protected getCacheType(gqlType: GraphQLOutputType): GraphQLOutputType;
|
|
744
|
+
protected getCacheType(gqlType: GraphQLOutputType, fieldName?: string): GraphQLOutputType;
|
|
634
745
|
get options(): {
|
|
635
746
|
resolverOptions: ResolvingOptions | undefined;
|
|
636
747
|
weaverContext: WeaverContext;
|
|
637
748
|
};
|
|
638
749
|
}
|
|
750
|
+
declare const OPERATION_OBJECT_NAMES: Set<string>;
|
|
639
751
|
declare function getCacheType(gqlType: GraphQLOutputType, options?: {
|
|
640
752
|
weaverContext?: WeaverContext;
|
|
641
753
|
resolverOptions?: ResolvingOptions;
|
|
754
|
+
fieldName?: string;
|
|
755
|
+
parent?: LoomObjectType;
|
|
642
756
|
}): GraphQLOutputType;
|
|
643
757
|
|
|
644
758
|
interface SchemaWeaverParameters extends Partial<Record<"query" | "mutation" | "subscription", LoomObjectType>>, Pick<GraphQLSchemaConfig, "types"> {
|
|
645
759
|
}
|
|
646
|
-
declare class
|
|
760
|
+
declare class GraphQLSchemaLoom {
|
|
647
761
|
query?: LoomObjectType;
|
|
648
762
|
mutation?: LoomObjectType;
|
|
649
763
|
subscription?: LoomObjectType;
|
|
@@ -659,7 +773,7 @@ declare class SchemaWeaver {
|
|
|
659
773
|
constructor({ query, mutation, subscription, types }?: SchemaWeaverParameters, context?: WeaverContext);
|
|
660
774
|
use(...middlewares: Middleware[]): this;
|
|
661
775
|
add(resolver: SilkResolver): this;
|
|
662
|
-
addVendor(weaver:
|
|
776
|
+
addVendor(weaver: SchemaWeaver): this;
|
|
663
777
|
addType(silk: GraphQLSilk): this;
|
|
664
778
|
setConfig<TConfig extends WeaverConfig>(config: TConfig): this;
|
|
665
779
|
weaveGraphQLSchema(): GraphQLSchema;
|
|
@@ -669,31 +783,34 @@ declare class SchemaWeaver {
|
|
|
669
783
|
resolverOptions: ResolvingOptions | undefined;
|
|
670
784
|
weaverContext: WeaverContext;
|
|
671
785
|
};
|
|
672
|
-
static optionsFrom(...inputs: (SilkResolver | Middleware |
|
|
786
|
+
static optionsFrom(...inputs: (SilkResolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): {
|
|
673
787
|
context: WeaverContext | undefined;
|
|
674
788
|
configs: Set<WeaverConfig>;
|
|
675
789
|
middlewares: Set<Middleware>;
|
|
676
790
|
resolvers: Set<SilkResolver>;
|
|
677
791
|
silks: Set<GraphQLSilk<any, any>>;
|
|
678
|
-
weavers: Set<
|
|
792
|
+
weavers: Set<SchemaWeaver>;
|
|
679
793
|
};
|
|
680
794
|
/**
|
|
681
795
|
* Weave a GraphQL Schema from resolvers
|
|
682
|
-
* @param inputs Resolvers, Global Middlewares
|
|
683
|
-
* @returns
|
|
796
|
+
* @param inputs Resolvers, Global Middlewares, WeaverConfigs Or SchemaWeaver
|
|
797
|
+
* @returns GraphQL Schema
|
|
684
798
|
*/
|
|
685
|
-
static weave(...inputs: (SilkResolver | Middleware |
|
|
799
|
+
static weave(...inputs: (SilkResolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): GraphQLSchema;
|
|
686
800
|
}
|
|
687
801
|
/**
|
|
688
802
|
* Weave a GraphQL Schema from resolvers
|
|
689
803
|
* @param inputs Resolvers, Global Middlewares or WeaverConfigs
|
|
690
804
|
* @returns GraphQ LSchema
|
|
691
805
|
*/
|
|
692
|
-
declare const weave: typeof
|
|
806
|
+
declare const weave: typeof GraphQLSchemaLoom.weave;
|
|
693
807
|
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
808
|
+
interface EnsureInputOptions {
|
|
809
|
+
fieldName?: string;
|
|
810
|
+
}
|
|
811
|
+
declare function inputToArgs(input: InputSchema<GraphQLSilk>, options: EnsureInputOptions | undefined): GraphQLFieldConfigArgumentMap | undefined;
|
|
812
|
+
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions | undefined): GraphQLInputType;
|
|
813
|
+
declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions | undefined): GraphQLInputObjectType;
|
|
697
814
|
|
|
698
815
|
declare function ensureInterfaceType(gqlType: GraphQLOutputType, interfaceConfig?: Partial<GraphQLInterfaceTypeConfig<any, any>>): GraphQLInterfaceType;
|
|
699
816
|
|
|
@@ -711,4 +828,4 @@ interface GQLoomExtensionAttribute {
|
|
|
711
828
|
directives?: string[];
|
|
712
829
|
}
|
|
713
830
|
|
|
714
|
-
export { type AbstractSchemaIO, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, type FieldConvertOptions, type FieldFactory, type FieldFactoryWithUtils, type FieldOptions, type FieldOrOperation, type FieldOrOperationType, type GQLoomExtensionAttribute, type GQLoomExtensions, type GenericFieldOrOperation, type GlobalWeaverContext, type GraphQLFieldOptions, type GraphQLSilk, type GraphQLSilkIO, type InferFieldInput, type InferFieldOutput, type InferFieldParent, type InferInputI, type InferInputO, type InferPropertyType, type InferSchemaI, type InferSchemaO, type InputSchema, type InputSchemaToSilk, type IsAny, type ListSilk, LoomObjectType, type MayPromise, type Middleware, type MiddlewareOptions, type MutationFactory, type NonNullSilk, type NullableSilk, type ObjectOrNever, type OnlyMemoizationPayload, type OperationType, type QueryFactory, type QueryMutationOptions, type ResolverFactory, type ResolverOptions, ResolverOptionsMap, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaToSilk, type
|
|
831
|
+
export { type AbstractSchemaIO, type BatchLoadFn, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, type FieldConvertOptions, type FieldFactory, type FieldFactoryWithUtils, type FieldOptions, type FieldOrOperation, type FieldOrOperationType, type GQLoomExtensionAttribute, type GQLoomExtensions, type GenericFieldOrOperation, type GlobalWeaverContext, type GraphQLFieldOptions, GraphQLSchemaLoom, type GraphQLSilk, type GraphQLSilkIO, type InferFieldInput, type InferFieldOutput, type InferFieldParent, type InferInputI, type InferInputO, type InferPropertyType, type InferSchemaI, type InferSchemaO, type InputSchema, type InputSchemaToSilk, type IsAny, type ListSilk, LoomObjectType, type MayPromise, type Middleware, type MiddlewareOptions, type MutationFactory, type MutationFactoryWithChain, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, type ObjectOrNever, type OnlyMemoizationPayload, type OperationType, type QueryFactory, type QueryFactoryWithChain, type QueryMutationOptions, type ResolverFactory, type ResolverOptions, ResolverOptionsMap, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaToSilk, type SchemaWeaver, type SilkFieldOrOperation, type SilkResolver, StandardSchemaV1, type Subscription, type SubscriptionFactory, type SubscriptionFactoryWithChain, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, type WrapPropertyType, applyMiddlewares, baseResolver, capitalize, collectName, collectNames, compose, createField, createFieldFactory, createInputParser, createLoom, createMemoization, createMutation, createMutationFactory, createQuery, createQueryFactory, createResolverFactory, createSubscription, createSubscriptionFactory, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getStandardValue, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, mutation, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseSilk, pascalCase, provideWeaverContext, query, resolver, resolverPayloadStorage, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
|