@gqloom/core 0.2.2 → 0.4.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/dist/index.d.cts CHANGED
@@ -1,6 +1,108 @@
1
- import { GraphQLOutputType, GraphQLObjectTypeConfig, GraphQLFieldConfig, GraphQLResolveInfo, GraphQLScalarType, GraphQLObjectType, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLSchemaConfig, GraphQLFieldMap, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig, GraphQLFieldExtensions, GraphQLObjectTypeExtensions } from 'graphql';
1
+ import { GraphQLOutputType, GraphQLObjectTypeConfig, GraphQLFieldConfig, GraphQLResolveInfo, GraphQLScalarType, GraphQLObjectType, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLSchemaConfig, GraphQLFieldMap, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
2
2
  import { AsyncLocalStorage } from 'async_hooks';
3
3
 
4
+ declare namespace v1 {
5
+ /**
6
+ * The Standard Schema interface.
7
+ */
8
+ interface StandardSchema<Input = unknown, Output = Input> {
9
+ /**
10
+ * The Standard Schema properties.
11
+ */
12
+ readonly "~standard": StandardSchemaProps<Input, Output>;
13
+ }
14
+ /**
15
+ * The Standard Schema properties interface.
16
+ */
17
+ interface StandardSchemaProps<Input = unknown, Output = Input> {
18
+ /**
19
+ * The version number of the standard.
20
+ */
21
+ readonly version: 1;
22
+ /**
23
+ * The vendor name of the schema library.
24
+ */
25
+ readonly vendor: string;
26
+ /**
27
+ * Validates unknown input values.
28
+ */
29
+ readonly validate: (value: unknown) => StandardResult<Output> | Promise<StandardResult<Output>>;
30
+ /**
31
+ * Inferred types associated with the schema.
32
+ */
33
+ readonly types?: StandardTypes<Input, Output> | undefined;
34
+ }
35
+ /**
36
+ * The result interface of the validate function.
37
+ */
38
+ type StandardResult<Output> = StandardSuccessResult<Output> | StandardFailureResult;
39
+ /**
40
+ * The result interface if validation succeeds.
41
+ */
42
+ interface StandardSuccessResult<Output> {
43
+ /**
44
+ * The typed output value.
45
+ */
46
+ readonly value: Output;
47
+ /**
48
+ * The non-existent issues.
49
+ */
50
+ readonly issues?: undefined;
51
+ }
52
+ /**
53
+ * The result interface if validation fails.
54
+ */
55
+ interface StandardFailureResult {
56
+ /**
57
+ * The issues of failed validation.
58
+ */
59
+ readonly issues: ReadonlyArray<StandardIssue>;
60
+ }
61
+ /**
62
+ * The issue interface of the failure output.
63
+ */
64
+ interface StandardIssue {
65
+ /**
66
+ * The error message of the issue.
67
+ */
68
+ readonly message: string;
69
+ /**
70
+ * The path of the issue, if any.
71
+ */
72
+ readonly path?: ReadonlyArray<PropertyKey | StandardPathSegment> | undefined;
73
+ }
74
+ /**
75
+ * The path segment interface of the issue.
76
+ */
77
+ interface StandardPathSegment {
78
+ /**
79
+ * The key representing a path segment.
80
+ */
81
+ readonly key: PropertyKey;
82
+ }
83
+ /**
84
+ * The base types interface of Standard Schema.
85
+ */
86
+ interface StandardTypes<Input, Output> {
87
+ /**
88
+ * The input type of the schema.
89
+ */
90
+ readonly input: Input;
91
+ /**
92
+ * The output type of the schema.
93
+ */
94
+ readonly output: Output;
95
+ }
96
+ /**
97
+ * Infers the input type of a Standard Schema.
98
+ */
99
+ type InferInput<Schema extends StandardSchema> = NonNullable<Schema["~standard"]["types"]>["input"];
100
+ /**
101
+ * Infers the output type of a Standard Schema.
102
+ */
103
+ type InferOutput<Schema extends StandardSchema> = NonNullable<Schema["~standard"]["types"]>["output"];
104
+ }
105
+
4
106
  type MayPromise<T> = T | Promise<T>;
5
107
  type IsAny<T> = 0 extends 1 & T ? true : false;
6
108
  /**
@@ -28,6 +130,36 @@ type WrapPropertyType<TKey extends string, TProperty> = TKey extends `${infer TF
28
130
  type ObjectOrNever<T> = T extends object ? T : never;
29
131
  type ValueOf<T extends object> = T[keyof T];
30
132
 
133
+ /**
134
+ * The symbol to get GraphQL type for schema
135
+ */
136
+ declare const GET_GRAPHQL_TYPE: unique symbol;
137
+ /**
138
+ * The symbol to get and store weaver config
139
+ */
140
+ declare const WEAVER_CONFIG: unique symbol;
141
+ /**
142
+ * The symbol to get resolver options
143
+ */
144
+ declare const RESOLVER_OPTIONS_KEY: unique symbol;
145
+ /**
146
+ * The symbol to assign a WeakMap to an object
147
+ */
148
+ declare const CONTEXT_MEMORY_MAP_KEY: unique symbol;
149
+ /**
150
+ * The symbol to set fields to be hidden
151
+ */
152
+ declare const FIELD_HIDDEN: unique symbol;
153
+
154
+ declare const symbols_CONTEXT_MEMORY_MAP_KEY: typeof CONTEXT_MEMORY_MAP_KEY;
155
+ declare const symbols_FIELD_HIDDEN: typeof FIELD_HIDDEN;
156
+ declare const symbols_GET_GRAPHQL_TYPE: typeof GET_GRAPHQL_TYPE;
157
+ declare const symbols_RESOLVER_OPTIONS_KEY: typeof RESOLVER_OPTIONS_KEY;
158
+ declare const symbols_WEAVER_CONFIG: typeof WEAVER_CONFIG;
159
+ declare namespace symbols {
160
+ export { symbols_CONTEXT_MEMORY_MAP_KEY as CONTEXT_MEMORY_MAP_KEY, symbols_FIELD_HIDDEN as FIELD_HIDDEN, symbols_GET_GRAPHQL_TYPE as GET_GRAPHQL_TYPE, symbols_RESOLVER_OPTIONS_KEY as RESOLVER_OPTIONS_KEY, symbols_WEAVER_CONFIG as WEAVER_CONFIG };
161
+ }
162
+
31
163
  type InputSchema<TBaseSchema> = TBaseSchema | Record<string, TBaseSchema> | undefined;
32
164
  type InputSchemaToSilk<TSchemaIO extends AbstractSchemaIO, TInput extends InputSchema<TSchemaIO[0]>> = TInput extends undefined ? undefined : TInput extends TSchemaIO[0] ? SchemaToSilk<TSchemaIO, TInput> : {
33
165
  [K in keyof TInput]: TInput[K] extends TSchemaIO[0] ? SchemaToSilk<TSchemaIO, TInput[K]> : never;
@@ -50,63 +182,23 @@ interface CallableInputParser<TSchema extends InputSchema<GraphQLSilk>> {
50
182
  /**
51
183
  * Parse the input and return the
52
184
  */
53
- (): Promise<InferInputO<TSchema, GraphQLSilkIO>>;
185
+ (): Promise<v1.StandardResult<InferInputO<TSchema, GraphQLSilkIO>>>;
54
186
  /**
55
187
  * Result of parsing. Set it to `undefined` then the parser will run again.
56
188
  */
57
- result: InferInputO<TSchema, GraphQLSilkIO> | undefined;
189
+ result: v1.StandardResult<InferInputO<TSchema, GraphQLSilkIO>> | undefined;
58
190
  }
59
191
  declare function createInputParser<TSchema extends InputSchema<GraphQLSilk> | undefined>(schema: TSchema, value: InferInputI<TSchema, GraphQLSilkIO>): CallableInputParser<TSchema>;
60
- declare function parseInputValue<TSchema extends InputSchema<GraphQLSilk> | undefined>(inputSchema: TSchema, input: any): MayPromise<InferInputO<TSchema, GraphQLSilkIO>>;
192
+ declare function parseInputValue<TSchema extends InputSchema<GraphQLSilk> | undefined>(inputSchema: TSchema, input: any): MayPromise<v1.StandardResult<InferInputO<TSchema, GraphQLSilkIO>>>;
193
+ declare function getStandardValue<T>(result: v1.StandardResult<T>): T;
194
+ declare function getStandardValue<T>(result?: v1.StandardResult<T>): T | undefined;
195
+ declare function getStandardValue<T>(result: v1.StandardResult<T> | null): T | null;
61
196
 
62
- /**
63
- * The symbol to get GraphQL type for schema
64
- */
65
- declare const GET_GRAPHQL_TYPE: unique symbol;
66
- /**
67
- * The symbol to validate and transform input to output
68
- */
69
- declare const PARSE: unique symbol;
70
- /**
71
- * The symbol to get and store weaver config
72
- */
73
- declare const WEAVER_CONFIG: unique symbol;
74
- /**
75
- * The symbol to get resolver options
76
- */
77
- declare const RESOLVER_OPTIONS_KEY: unique symbol;
78
- /**
79
- * The symbol to assign a WeakMap to an object
80
- */
81
- declare const CONTEXT_MEMORY_MAP_KEY: unique symbol;
82
-
83
- declare const symbols_CONTEXT_MEMORY_MAP_KEY: typeof CONTEXT_MEMORY_MAP_KEY;
84
- declare const symbols_GET_GRAPHQL_TYPE: typeof GET_GRAPHQL_TYPE;
85
- declare const symbols_PARSE: typeof PARSE;
86
- declare const symbols_RESOLVER_OPTIONS_KEY: typeof RESOLVER_OPTIONS_KEY;
87
- declare const symbols_WEAVER_CONFIG: typeof WEAVER_CONFIG;
88
- declare namespace symbols {
89
- export { symbols_CONTEXT_MEMORY_MAP_KEY as CONTEXT_MEMORY_MAP_KEY, symbols_GET_GRAPHQL_TYPE as GET_GRAPHQL_TYPE, symbols_PARSE as PARSE, symbols_RESOLVER_OPTIONS_KEY as RESOLVER_OPTIONS_KEY, symbols_WEAVER_CONFIG as WEAVER_CONFIG };
90
- }
91
-
92
- interface GraphQLSilk<TOutput = any, TInput = any> {
197
+ interface GraphQLSilk<TOutput = any, TInput = any> extends v1.StandardSchema<TInput, TOutput> {
93
198
  /**
94
199
  * GraphQL type for schema
95
200
  */
96
- [GET_GRAPHQL_TYPE]: () => GraphQLOutputType;
97
- /**
98
- * validate and transform input to output
99
- */
100
- [PARSE]?: (input: TInput) => MayPromise<TOutput>;
101
- /**
102
- * Input and output type.
103
- *
104
- * @internal
105
- */
106
- readonly "~types"?: {
107
- readonly input: TInput;
108
- readonly output: TOutput;
109
- };
201
+ [GET_GRAPHQL_TYPE]?: () => GraphQLOutputType;
110
202
  }
111
203
  type AbstractSchemaIO = [
112
204
  baseSchema: object,
@@ -115,11 +207,9 @@ type AbstractSchemaIO = [
115
207
  ];
116
208
  type GraphQLSilkIO = [
117
209
  object: GraphQLSilk,
118
- input: "~types.input",
119
- output: "~types.output"
210
+ input: "~standard.types.input",
211
+ output: "~standard.types.output"
120
212
  ];
121
- type InferSilkI<T extends GraphQLSilk> = NonNullable<T["~types"]>["input"];
122
- type InferSilkO<T extends GraphQLSilk> = NonNullable<T["~types"]>["output"];
123
213
  type InferSchemaI<TSchema, TSchemaIO extends AbstractSchemaIO> = InferPropertyType<TSchema, TSchemaIO[1]>;
124
214
  type InferSchemaO<TSchema, TSchemaIO extends AbstractSchemaIO> = InferPropertyType<TSchema, TSchemaIO[2]>;
125
215
  type SchemaToSilk<TSchemaIO extends AbstractSchemaIO, TSchema extends TSchemaIO[0]> = GraphQLSilk<InferSchemaO<TSchema, TSchemaIO>, InferSchemaI<TSchema, TSchemaIO>>;
@@ -144,7 +234,7 @@ interface FieldOrOperation<TParent extends undefined | GraphQLSilk, TOutput exte
144
234
  type: TType;
145
235
  input: TInput;
146
236
  output: TOutput;
147
- resolve: TType extends "field" ? (parent: InferSilkO<NonNullable<TParent>>, input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => Promise<InferSilkO<TOutput>> : TType extends "subscription" ? (value: any, input: InferInputI<TInput, GraphQLSilkIO>) => Promise<InferSilkO<TOutput>> : (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => Promise<InferSilkO<TOutput>>;
237
+ resolve: TType extends "field" ? (parent: v1.InferOutput<NonNullable<TParent>>, input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => Promise<v1.InferOutput<TOutput>> : TType extends "subscription" ? (value: any, input: InferInputI<TInput, GraphQLSilkIO>) => Promise<v1.InferOutput<TOutput>> : (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => Promise<v1.InferOutput<TOutput>>;
148
238
  subscribe?: TType extends "subscription" ? (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => MayPromise<AsyncIterator<any>> : undefined;
149
239
  }
150
240
  type GenericFieldOrOperation = FieldOrOperation<any, any, any, any>;
@@ -159,10 +249,16 @@ interface QueryMutationOptions<TSchemaIO extends AbstractSchemaIO, TOutput exten
159
249
  resolve: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>;
160
250
  }
161
251
  /**
162
- * Function to create a GraphQL query or mutation.
252
+ * Function to create a GraphQL query.
163
253
  */
164
- interface QueryMutationBobbin<TSchemaIO extends AbstractSchemaIO> {
165
- <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" | "mutation">;
254
+ interface QueryFactory<TSchemaIO extends AbstractSchemaIO> {
255
+ <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">;
256
+ }
257
+ /**
258
+ * Function to create a GraphQL mutation.
259
+ */
260
+ interface MutationFactory<TSchemaIO extends AbstractSchemaIO> {
261
+ <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">;
166
262
  }
167
263
  /**
168
264
  * Options for External Filed of existing GraphQL Object.
@@ -174,9 +270,13 @@ interface FieldOptions<TSchemaIO extends AbstractSchemaIO, TParent extends TSche
174
270
  /**
175
271
  * Function to create a GraphQL Field.
176
272
  */
177
- interface FieldBobbin<TSchemaIO extends AbstractSchemaIO> {
273
+ interface FieldFactory<TSchemaIO extends AbstractSchemaIO> {
178
274
  <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">;
179
275
  }
276
+ interface FieldFactoryWithUtils<TSchemaIO extends AbstractSchemaIO> extends FieldFactory<TSchemaIO> {
277
+ /** Set fields to be hidden in GraphQL Schema */
278
+ hidden: typeof FIELD_HIDDEN;
279
+ }
180
280
  /**
181
281
  * Options for creating a GraphQL Subscription.
182
282
  */
@@ -185,20 +285,21 @@ interface SubscriptionOptions<TSchemaIO extends AbstractSchemaIO, TOutput extend
185
285
  subscribe: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<AsyncIterator<TValue>>;
186
286
  resolve?: (value: TValue, input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>;
187
287
  }
188
- interface Subscription<TOutput extends GraphQLSilk, TInput extends InputSchema<GraphQLSilk> = undefined, TValue = InferSilkO<TOutput>> extends FieldOrOperation<undefined, TOutput, TInput, "subscription"> {
189
- resolve: (value: TValue, input: InferInputI<TInput, GraphQLSilkIO>) => Promise<InferSilkO<TOutput>>;
288
+ interface Subscription<TOutput extends GraphQLSilk, TInput extends InputSchema<GraphQLSilk> = undefined, TValue = v1.InferOutput<TOutput>> extends FieldOrOperation<undefined, TOutput, TInput, "subscription"> {
289
+ resolve: (value: TValue, input: InferInputI<TInput, GraphQLSilkIO>) => Promise<v1.InferOutput<TOutput>>;
190
290
  subscribe: (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => MayPromise<AsyncIterator<TValue>>;
191
291
  }
192
292
  /**
193
293
  * Function to create a GraphQL subscription.
194
294
  */
195
- interface SubscriptionBobbin<TSchemaIO extends AbstractSchemaIO> {
295
+ interface SubscriptionFactory<TSchemaIO extends AbstractSchemaIO> {
196
296
  <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>;
197
297
  }
198
- interface ResolverBobbin<TSchemaIO extends AbstractSchemaIO> {
199
- of<TParent extends TSchemaIO[0], TOperations extends Record<string, FieldOrOperation<SchemaToSilk<TSchemaIO, TParent>, any, any> | FieldOrOperation<undefined, any, any, OperationType>>>(parent: TParent, operationOrFields: TOperations, options?: ResolverOptionsWithExtensions<ValueOf<TOperations>>): TOperations;
298
+ interface ResolverFactory<TSchemaIO extends AbstractSchemaIO> {
299
+ 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;
200
300
  <TOperations extends Record<string, FieldOrOperation<undefined, any, any, OperationType>>>(operations: TOperations, options?: ResolverOptions<ValueOf<TOperations>>): TOperations;
201
301
  }
302
+ type OmitInUnion<TUnion, TOmit> = TUnion extends infer T ? T extends TOmit ? never : T : never;
202
303
 
203
304
  declare function getOperationOptions<T extends FieldOrOperationType = OperationType>(resolveOrOptions: T extends "field" ? ((parent: any) => any) | FieldOptions<any, any, any, any> : (() => any) | QueryMutationOptions<any, any, any>): T extends "field" ? FieldOptions<any, any, any, any> : QueryMutationOptions<any, any, any>;
204
305
  declare function getSubscriptionOptions(subscribeOrOptions: (() => any) | SubscriptionOptions<any, any, any, any>): SubscriptionOptions<any, any, any, any>;
@@ -206,16 +307,16 @@ declare function getFieldOptions({ description, deprecationReason, extensions, }
206
307
 
207
308
  interface MiddlewarePayload<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>> {
208
309
  /** The Output Silk of the field */
209
- outputSilk: InferSilkO<InferFieldOutput<TField>>;
310
+ outputSilk: v1.InferOutput<InferFieldOutput<TField>>;
210
311
  /** The previous object, which for a field on the root Query type is often not used. */
211
- parent: TField extends FieldOrOperation<infer TParent, any, any, any> ? TParent extends undefined ? undefined : InferSilkO<NonNullable<TParent>> : never;
312
+ parent: TField extends FieldOrOperation<infer TParent, any, any, any> ? TParent extends undefined ? undefined : v1.InferOutput<NonNullable<TParent>> : never;
212
313
  /** A function to parse the input of the field */
213
314
  parseInput: TField extends FieldOrOperation<any, any, infer TInput, any> ? CallableInputParser<TInput> : undefined;
214
315
  /** The type of the field: `query`, `mutation`, `subscription` or `field` */
215
316
  type: FieldOrOperationType;
216
317
  }
217
- type Middleware<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>> = (next: () => MayPromise<InferSilkO<InferFieldOutput<TField>>>, payload: MiddlewarePayload<TField>) => MayPromise<InferSilkO<InferFieldOutput<TField>>>;
218
- declare function applyMiddlewares<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>>(middlewares: Middleware[], resolveFunction: () => MayPromise<InferSilkO<InferFieldOutput<TField>>>, payload: MiddlewarePayload<TField>): Promise<InferSilkO<InferFieldOutput<TField>>>;
318
+ type Middleware<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>> = (next: () => MayPromise<v1.InferOutput<InferFieldOutput<TField>>>, payload: MiddlewarePayload<TField>) => MayPromise<v1.InferOutput<InferFieldOutput<TField>>>;
319
+ declare function applyMiddlewares<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>>(middlewares: Middleware[], resolveFunction: () => MayPromise<v1.InferOutput<InferFieldOutput<TField>>>, payload: MiddlewarePayload<TField>): Promise<v1.InferOutput<InferFieldOutput<TField>>>;
219
320
  declare function compose<T>(...lists: (T[] | undefined)[]): T[];
220
321
 
221
322
  /**
@@ -359,11 +460,11 @@ declare function markLocation(message: string, ...locations: string[]): string;
359
460
  /**
360
461
  * Create a Silk from Scalar.
361
462
  */
362
- declare function silk<TScalar extends GraphQLScalarType>(type: TScalar, parse?: (input: InferScalarExternal<TScalar>) => MayPromise<InferScalarInternal<TScalar>>): GraphQLSilk<InferScalarInternal<TScalar> | undefined, InferScalarInternal<TScalar> | undefined>;
463
+ declare function silk<TScalar extends GraphQLScalarType>(type: TScalar | (() => TScalar), parse?: (value: InferScalarExternal<TScalar>) => v1.StandardResult<InferScalarExternal<TScalar>> | Promise<v1.StandardResult<InferScalarInternal<TScalar>>>): GraphQLSilk<InferScalarInternal<TScalar> | undefined, InferScalarInternal<TScalar> | undefined>;
363
464
  /**
364
465
  * Create a GraphQLSilk Object.
365
466
  */
366
- declare function silk<TOutput, TInput = TOutput>(type: GraphQLOutputType, parse?: (input: TInput) => MayPromise<TOutput>): GraphQLSilk<TOutput, TInput>;
467
+ declare function silk<TOutput, TInput = TOutput>(type: GraphQLOutputType | (() => GraphQLOutputType), validate?: (value: TInput) => v1.StandardResult<TOutput> | Promise<v1.StandardResult<TOutput>>): GraphQLSilk<TOutput, TInput>;
367
468
  declare namespace silk {
368
469
  var parse: typeof parseSilk;
369
470
  var getType: typeof getGraphQLType;
@@ -371,17 +472,17 @@ declare namespace silk {
371
472
  var list: typeof listSilk;
372
473
  var nullable: typeof nullableSilk;
373
474
  }
374
- type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<InferSilkO<TSilk>>, NonNullable<InferSilkI<TSilk>>>;
475
+ type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<v1.InferOutput<TSilk>>, NonNullable<v1.InferInput<TSilk>>>;
375
476
  /**
376
477
  * Non-nullable Silk.
377
478
  */
378
479
  declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
379
- type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<EnsureArray<InferSilkO<TSilk>>, EnsureArray<InferSilkO<TSilk>>>;
480
+ type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<EnsureArray<v1.InferOutput<TSilk>>, EnsureArray<v1.InferOutput<TSilk>>>;
380
481
  /**
381
482
  * List Silk.
382
483
  */
383
484
  declare function listSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): ListSilk<TSilk>;
384
- type NullableSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<InferSilkO<TSilk> | null | undefined, InferSilkI<TSilk>>;
485
+ type NullableSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<v1.InferOutput<TSilk> | null | undefined, v1.InferInput<TSilk>>;
385
486
  /**
386
487
  * Nullable Silk.
387
488
  */
@@ -398,42 +499,49 @@ declare function getGraphQLType(silk: GraphQLSilk): GraphQLOutputType;
398
499
  * @param input
399
500
  * @returns output
400
501
  */
401
- declare function parseSilk<TSilk extends GraphQLSilk>(silk: TSilk, input: InferSilkI<TSilk>): MayPromise<InferSilkO<TSilk>>;
502
+ declare function parseSilk<TSilk extends GraphQLSilk>(silk: TSilk, input: v1.InferInput<TSilk>): MayPromise<v1.StandardResult<v1.InferOutput<TSilk>>>;
402
503
  declare function isSilk(target: any): target is GraphQLSilk;
403
504
  type InferScalarInternal<T extends GraphQLScalarType> = T extends GraphQLScalarType<infer TInternal> ? TInternal : never;
404
505
  type InferScalarExternal<T extends GraphQLScalarType> = T extends GraphQLScalarType<any, infer TExternal> ? TExternal : never;
405
506
  type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
406
507
 
407
- declare const silkQuery: QueryMutationBobbin<GraphQLSilkIO>;
408
- declare const silkMutation: QueryMutationBobbin<GraphQLSilkIO>;
409
- declare const silkField: FieldBobbin<GraphQLSilkIO>;
508
+ declare const query: QueryFactory<GraphQLSilkIO>;
509
+ declare const mutation: MutationFactory<GraphQLSilkIO>;
510
+ declare const field: FieldFactoryWithUtils<GraphQLSilkIO>;
410
511
  declare const defaultSubscriptionResolve: (source: any) => any;
411
- declare const silkSubscription: SubscriptionBobbin<GraphQLSilkIO>;
512
+ declare const subscription: SubscriptionFactory<GraphQLSilkIO>;
412
513
  declare const ResolverOptionsMap: WeakMap<object, ResolverOptionsWithParent<GenericFieldOrOperation>>;
413
514
  declare function baseResolver(operations: Record<string, FieldOrOperation<any, any, any>>, options: ResolverOptionsWithParent | undefined): Record<string, FieldOrOperation<any, any, any, FieldOrOperationType>>;
414
- declare const silkResolver: ResolverBobbin<GraphQLSilkIO>;
515
+ declare const resolver: ResolverFactory<GraphQLSilkIO>;
415
516
  declare const loom: {
416
- query: QueryMutationBobbin<GraphQLSilkIO>;
417
- resolver: ResolverBobbin<GraphQLSilkIO>;
418
- field: FieldBobbin<GraphQLSilkIO>;
419
- subscription: SubscriptionBobbin<GraphQLSilkIO>;
420
- mutation: QueryMutationBobbin<GraphQLSilkIO>;
517
+ query: QueryFactory<GraphQLSilkIO>;
518
+ resolver: ResolverFactory<GraphQLSilkIO>;
519
+ field: FieldFactoryWithUtils<GraphQLSilkIO>;
520
+ subscription: SubscriptionFactory<GraphQLSilkIO>;
521
+ mutation: MutationFactory<GraphQLSilkIO>;
421
522
  };
422
523
 
423
- declare function createResolverBobbin<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk): ResolverBobbin<TSchemaIO>;
424
- declare function createFieldBobbin<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): FieldBobbin<TSchemaIO>;
425
- declare function createQueryBobbin<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): QueryMutationBobbin<TSchemaIO>;
426
- declare function createMutationBobbin<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): QueryMutationBobbin<TSchemaIO>;
427
- declare function createSubscriptionBobbin<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): SubscriptionBobbin<TSchemaIO>;
524
+ declare function createResolverFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk): ResolverFactory<TSchemaIO>;
525
+ declare function createFieldFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): FieldFactoryWithUtils<TSchemaIO>;
526
+ declare function createQueryFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): QueryFactory<TSchemaIO>;
527
+ declare function createMutationFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): MutationFactory<TSchemaIO>;
528
+ declare function createSubscriptionFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): SubscriptionFactory<TSchemaIO>;
428
529
  declare function createLoom<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): {
429
- query: QueryMutationBobbin<TSchemaIO>;
430
- mutation: QueryMutationBobbin<TSchemaIO>;
431
- field: FieldBobbin<TSchemaIO>;
432
- resolver: ResolverBobbin<TSchemaIO>;
433
- subscription: SubscriptionBobbin<TSchemaIO>;
530
+ query: QueryFactory<TSchemaIO>;
531
+ mutation: MutationFactory<TSchemaIO>;
532
+ field: FieldFactoryWithUtils<TSchemaIO>;
533
+ resolver: ResolverFactory<TSchemaIO>;
534
+ subscription: SubscriptionFactory<TSchemaIO>;
434
535
  };
435
536
 
537
+ interface SchemaVendorWeaver {
538
+ vendor: string;
539
+ getGraphQLType: (schema: any) => GraphQLOutputType;
540
+ }
541
+ declare function isSchemaVendorWeaver(some: any): some is SchemaVendorWeaver;
542
+
436
543
  interface WeaverContext {
544
+ id: number;
437
545
  loomObjectMap: Map<GraphQLObjectType, LoomObjectType>;
438
546
  loomUnionMap: Map<GraphQLUnionType, GraphQLUnionType>;
439
547
  inputMap: Map<GraphQLObjectType | GraphQLInterfaceType, GraphQLInputObjectType>;
@@ -446,11 +554,16 @@ interface WeaverContext {
446
554
  memoNamedType<TGraphQLType extends GraphQLOutputType = GraphQLOutputType>(gqlType: TGraphQLType): TGraphQLType;
447
555
  getNamedType<T extends GraphQLOutputType>(name: string): T | undefined;
448
556
  names: WeakMap<object, string>;
557
+ vendorWeavers: Map<string, SchemaVendorWeaver>;
449
558
  }
450
559
  interface WeaverConfig {
451
560
  [WEAVER_CONFIG]: string | symbol;
561
+ vendorWeaver?: SchemaVendorWeaver;
452
562
  }
453
563
  declare function initWeaverContext(): WeaverContext;
564
+ declare namespace initWeaverContext {
565
+ var increasingID: number;
566
+ }
454
567
  type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "getNamedType" | "memoNamedType";
455
568
  interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextRequiredKeys>>, Pick<WeaverContext, GlobalContextRequiredKeys> {
456
569
  value?: WeaverContext;
@@ -461,19 +574,29 @@ interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextR
461
574
  }
462
575
  declare const weaverContext: GlobalWeaverContext;
463
576
  declare function provideWeaverContext<T>(func: () => T, value: WeaverContext | undefined): T;
577
+ declare namespace provideWeaverContext {
578
+ var inherit: <T>(func: () => T) => () => T;
579
+ }
464
580
  /**
465
581
  * collect names for schemas
466
582
  * @param namesList - names to collect
467
583
  * @returns namesRecord
468
584
  */
469
585
  declare function collectNames<TRecords extends Record<string, object>[]>(...namesList: TRecords): UnionToIntersection<TRecords[number]>;
586
+ /**
587
+ * collect name for schema
588
+ * @param name - name for
589
+ * @param schema - schema to be named
590
+ * @returns schema
591
+ */
592
+ declare function collectName<TSchema extends object>(name: string, schema: TSchema): TSchema;
470
593
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
471
594
 
472
595
  type SilkFieldOrOperation = FieldOrOperation<any, any, any, any>;
473
596
  interface FieldConvertOptions {
474
597
  optionsForResolving?: ResolvingOptions;
475
598
  }
476
- type SilkResolver = Record<string, FieldOrOperation<any, any, any, any>>;
599
+ type SilkResolver = Record<string, FieldOrOperation<any, any, any, any> | typeof FIELD_HIDDEN>;
477
600
  interface CoreSchemaWeaverConfigOptions extends GraphQLSchemaConfig {
478
601
  getInputObjectName?: (name: string) => string;
479
602
  weaverContext?: WeaverContext;
@@ -483,16 +606,18 @@ interface CoreSchemaWeaverConfig extends WeaverConfig, CoreSchemaWeaverConfigOpt
483
606
  }
484
607
 
485
608
  declare class LoomObjectType extends GraphQLObjectType {
486
- extraFields: Map<string, SilkFieldOrOperation>;
487
- weaverContext: WeaverContext;
488
- resolverOptions?: ResolvingOptions;
609
+ protected extraFields: Map<string, SilkFieldOrOperation>;
610
+ protected hiddenFields: Set<string>;
611
+ protected weaverContext: WeaverContext;
612
+ protected resolverOptions?: ResolvingOptions;
489
613
  constructor(objectOrGetter: string | GraphQLObjectType | GraphQLObjectTypeConfig<any, any> | (() => GraphQLObjectType | GraphQLObjectTypeConfig<any, any>), options?: {
490
614
  weaverContext?: WeaverContext;
491
615
  resolverOptions?: ResolvingOptions;
492
616
  });
617
+ hideField(name: string): void;
493
618
  addField(name: string, resolver: SilkFieldOrOperation): void;
494
619
  mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
495
- private extraField?;
620
+ private extraFieldMap?;
496
621
  getFields(): GraphQLFieldMap<any, any>;
497
622
  protected mapToFieldConfig(map: Map<string, SilkFieldOrOperation>): Record<string, GraphQLFieldConfig<any, any>>;
498
623
  toFieldConfig(field: SilkFieldOrOperation): GraphQLFieldConfig<any, any>;
@@ -527,6 +652,7 @@ declare class SchemaWeaver {
527
652
  constructor({ query, mutation, subscription, types }?: SchemaWeaverParameters, context?: WeaverContext);
528
653
  use(...middlewares: Middleware[]): this;
529
654
  add(resolver: SilkResolver): this;
655
+ addVendor(weaver: SchemaVendorWeaver): this;
530
656
  addType(silk: GraphQLSilk): this;
531
657
  setConfig<TConfig extends WeaverConfig>(config: TConfig): this;
532
658
  weaveGraphQLSchema(): GraphQLSchema;
@@ -536,19 +662,20 @@ declare class SchemaWeaver {
536
662
  resolverOptions: ResolvingOptions | undefined;
537
663
  weaverContext: WeaverContext;
538
664
  };
539
- static optionsFrom(...inputs: (SilkResolver | Middleware | WeaverConfig | GraphQLSilk)[]): {
665
+ static optionsFrom(...inputs: (SilkResolver | Middleware | SchemaVendorWeaver | WeaverConfig | GraphQLSilk)[]): {
540
666
  context: WeaverContext | undefined;
541
667
  configs: Set<WeaverConfig>;
542
668
  middlewares: Set<Middleware>;
543
669
  resolvers: Set<SilkResolver>;
544
670
  silks: Set<GraphQLSilk<any, any>>;
671
+ weavers: Set<SchemaVendorWeaver>;
545
672
  };
546
673
  /**
547
674
  * Weave a GraphQL Schema from resolvers
548
675
  * @param inputs Resolvers, Global Middlewares or WeaverConfigs
549
676
  * @returns GraphQ LSchema
550
677
  */
551
- static weave(...inputs: (SilkResolver | Middleware | WeaverConfig | GraphQLSilk)[]): GraphQLSchema;
678
+ static weave(...inputs: (SilkResolver | Middleware | SchemaVendorWeaver | WeaverConfig | GraphQLSilk)[]): GraphQLSchema;
552
679
  }
553
680
  /**
554
681
  * Weave a GraphQL Schema from resolvers
@@ -576,6 +703,5 @@ type DirectiveRecord = Record<string, Record<string, any>>;
576
703
  interface GQLoomExtensionAttribute {
577
704
  directives?: string[];
578
705
  }
579
- declare function mergeExtensions(...extensionsList: (Readonly<GraphQLFieldExtensions<any, any, any> | GraphQLObjectTypeExtensions | GQLoomExtensions> | null | undefined)[]): GraphQLFieldExtensions<any, any, any>;
580
706
 
581
- export { type AbstractSchemaIO, type CallableContextMemoization, type CallableInputParser, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, type FieldBobbin, type FieldConvertOptions, 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 InferSilkI, type InferSilkO, type InputSchema, type InputSchemaToSilk, type IsAny, type ListSilk, LoomObjectType, type MayPromise, type Middleware, type MiddlewarePayload, type NonNullSilk, type NullableSilk, type ObjectOrNever, type OnlyMemoizationPayload, type OperationType, type QueryMutationBobbin, type QueryMutationOptions, type ResolverBobbin, type ResolverOptions, ResolverOptionsMap, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaToSilk, SchemaWeaver, type SilkFieldOrOperation, type SilkResolver, type Subscription, type SubscriptionBobbin, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, type WrapPropertyType, applyMiddlewares, baseResolver, collectNames, compose, createFieldBobbin, createInputParser, createLoom, createMemoization, createMutationBobbin, createQueryBobbin, createResolverBobbin, createSubscriptionBobbin, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getSubscriptionOptions, initWeaverContext, inputToArgs, isOnlyMemoryPayload, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, mergeExtensions, nonNullSilk, notNullish, nullableSilk, onlyMemoization, parseInputValue, parseSilk, provideWeaverContext, resolverPayloadStorage, silk, silkField, silkMutation, silkQuery, silkResolver, silkSubscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, weave, weaverContext };
707
+ export { type AbstractSchemaIO, type CallableContextMemoization, type CallableInputParser, 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 MiddlewarePayload, 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 SchemaVendorWeaver, SchemaWeaver, type SilkFieldOrOperation, type SilkResolver, type Subscription, type SubscriptionFactory, type SubscriptionOptions, type ValueOf, type WeaverConfig, type WeaverContext, type WrapPropertyType, applyMiddlewares, baseResolver, collectName, collectNames, compose, createFieldFactory, createInputParser, createLoom, createMemoization, createMutationFactory, createQueryFactory, createResolverFactory, 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, provideWeaverContext, query, resolver, resolverPayloadStorage, silk, subscription, toObjMap, tryIn, useContext, useMemoizationMap, useResolverPayload, v1, weave, weaverContext };