@gqloom/core 0.7.2 → 0.8.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.ts CHANGED
@@ -1,138 +1,70 @@
1
1
  import * as graphql from 'graphql';
2
- import { GraphQLOutputType, GraphQLObjectTypeConfig, GraphQLFieldConfig, GraphQLResolveInfo, GraphQLScalarType, GraphQLObjectType, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLSchemaConfig, GraphQLFieldMap, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
2
+ import { GraphQLOutputType, GraphQLObjectTypeConfig, GraphQLFieldConfig, GraphQLScalarType, GraphQLObjectType, GraphQLNullableType, GraphQLList, GraphQLNonNull, GraphQLResolveInfo, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLFieldMap, GraphQLSchemaConfig, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
3
3
  import * as graphql_jsutils_Maybe from 'graphql/jsutils/Maybe';
4
4
  import { AsyncLocalStorage } from 'async_hooks';
5
5
 
6
- /**
7
- * The Standard Schema interface.
8
- */
9
- type StandardSchemaV1<Input = unknown, Output = Input> = {
10
- /**
11
- * The Standard Schema properties.
12
- */
6
+ type MayPromise<T> = T | Promise<T>;
7
+ type IsAny<T> = 0 extends 1 & T ? true : false;
8
+ type ValueOf<T extends object> = T[keyof T];
9
+ type OmitInUnion<TUnion, TOmit> = TUnion extends infer T ? T extends TOmit ? never : T : never;
10
+
11
+ /** The Standard Schema interface. */
12
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
13
+ /** The Standard Schema properties. */
13
14
  readonly "~standard": StandardSchemaV1.Props<Input, Output>;
14
- };
15
+ }
15
16
  declare namespace StandardSchemaV1 {
16
- /**
17
- * The Standard Schema properties interface.
18
- */
17
+ /** The Standard Schema properties interface. */
19
18
  export interface Props<Input = unknown, Output = Input> {
20
- /**
21
- * The version number of the standard.
22
- */
19
+ /** The version number of the standard. */
23
20
  readonly version: 1;
24
- /**
25
- * The vendor name of the schema library.
26
- */
21
+ /** The vendor name of the schema library. */
27
22
  readonly vendor: string;
28
- /**
29
- * Validates unknown input values.
30
- */
23
+ /** Validates unknown input values. */
31
24
  readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
32
- /**
33
- * Inferred types associated with the schema.
34
- */
25
+ /** Inferred types associated with the schema. */
35
26
  readonly types?: Types<Input, Output> | undefined;
36
27
  }
37
- /**
38
- * The result interface of the validate function.
39
- */
28
+ /** The result interface of the validate function. */
40
29
  export type Result<Output> = SuccessResult<Output> | FailureResult;
41
- /**
42
- * The result interface if validation succeeds.
43
- */
30
+ /** The result interface if validation succeeds. */
44
31
  export interface SuccessResult<Output> {
45
- /**
46
- * The typed output value.
47
- */
32
+ /** The typed output value. */
48
33
  readonly value: Output;
49
- /**
50
- * The non-existent issues.
51
- */
34
+ /** The non-existent issues. */
52
35
  readonly issues?: undefined;
53
36
  }
54
- /**
55
- * The result interface if validation fails.
56
- */
37
+ /** The result interface if validation fails. */
57
38
  export interface FailureResult {
58
- /**
59
- * The issues of failed validation.
60
- */
39
+ /** The issues of failed validation. */
61
40
  readonly issues: ReadonlyArray<Issue>;
62
41
  }
63
- /**
64
- * The issue interface of the failure output.
65
- */
42
+ /** The issue interface of the failure output. */
66
43
  export interface Issue {
67
- /**
68
- * The error message of the issue.
69
- */
44
+ /** The error message of the issue. */
70
45
  readonly message: string;
71
- /**
72
- * The path of the issue, if any.
73
- */
46
+ /** The path of the issue, if any. */
74
47
  readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
75
48
  }
76
- /**
77
- * The path segment interface of the issue.
78
- */
49
+ /** The path segment interface of the issue. */
79
50
  export interface PathSegment {
80
- /**
81
- * The key representing a path segment.
82
- */
51
+ /** The key representing a path segment. */
83
52
  readonly key: PropertyKey;
84
53
  }
85
- /**
86
- * The Standard Schema types interface.
87
- */
54
+ /** The Standard Schema types interface. */
88
55
  export interface Types<Input = unknown, Output = Input> {
89
- /**
90
- * The input type of the schema.
91
- */
56
+ /** The input type of the schema. */
92
57
  readonly input: Input;
93
- /**
94
- * The output type of the schema.
95
- */
58
+ /** The output type of the schema. */
96
59
  readonly output: Output;
97
60
  }
98
- /**
99
- * Infers the input type of a Standard Schema.
100
- */
61
+ /** Infers the input type of a Standard Schema. */
101
62
  export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
102
- /**
103
- * Infers the output type of a Standard Schema.
104
- */
63
+ /** Infers the output type of a Standard Schema. */
105
64
  export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
106
65
  export { };
107
66
  }
108
67
 
109
- type MayPromise<T> = T | Promise<T>;
110
- type IsAny<T> = 0 extends 1 & T ? true : false;
111
- /**
112
- * @example
113
- * ```TypeScript
114
- * type A = { a?: { b?: { c: string } } }
115
- * type B = InferPropertyType<A, "a"> // { b?: { c: string } }
116
- * type C = InferPropertyType<A, "a.b"> // { c: string }
117
- * ```
118
- */
119
- type InferPropertyType<T, K extends string> = K extends `${infer K1}.${infer K2}` ? K1 extends keyof T ? InferPropertyType<NonNullable<T[K1]>, K2> : never : K extends keyof T ? T[K] : never;
120
- /**
121
- * @example
122
- * ```TypeScript
123
- * type C = { c: string }
124
- * type A = WrapPropertyType<"a", C> // { a: C }
125
- * type B = WrapPropertyType<"a.b", C> // { a: { b: C } }
126
- * ```
127
- */
128
- type WrapPropertyType<TKey extends string, TProperty> = TKey extends `${infer TFirst}.${infer TRest}` ? {
129
- [K in TFirst]: WrapPropertyType<TRest, TProperty>;
130
- } : {
131
- [K in TKey]: TProperty;
132
- };
133
- type ObjectOrNever<T> = T extends object ? T : never;
134
- type ValueOf<T extends object> = T[keyof T];
135
-
136
68
  /**
137
69
  * The symbol to get GraphQL type for schema
138
70
  */
@@ -145,6 +77,10 @@ declare const WEAVER_CONFIG: unique symbol;
145
77
  * The symbol to get resolver options
146
78
  */
147
79
  declare const RESOLVER_OPTIONS_KEY: unique symbol;
80
+ /**
81
+ * The symbol to check if an object is a resolver
82
+ */
83
+ declare const IS_RESOLVER: unique symbol;
148
84
  /**
149
85
  * The symbol to assign a WeakMap to an object
150
86
  */
@@ -157,23 +93,20 @@ declare const FIELD_HIDDEN: unique symbol;
157
93
  declare const symbols_CONTEXT_MEMORY_MAP_KEY: typeof CONTEXT_MEMORY_MAP_KEY;
158
94
  declare const symbols_FIELD_HIDDEN: typeof FIELD_HIDDEN;
159
95
  declare const symbols_GET_GRAPHQL_TYPE: typeof GET_GRAPHQL_TYPE;
96
+ declare const symbols_IS_RESOLVER: typeof IS_RESOLVER;
160
97
  declare const symbols_RESOLVER_OPTIONS_KEY: typeof RESOLVER_OPTIONS_KEY;
161
98
  declare const symbols_WEAVER_CONFIG: typeof WEAVER_CONFIG;
162
99
  declare namespace symbols {
163
- 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 };
100
+ 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_IS_RESOLVER as IS_RESOLVER, symbols_RESOLVER_OPTIONS_KEY as RESOLVER_OPTIONS_KEY, symbols_WEAVER_CONFIG as WEAVER_CONFIG };
164
101
  }
165
102
 
166
- type InputSchema<TBaseSchema> = TBaseSchema | Record<string, TBaseSchema> | undefined;
167
- type InputSchemaToSilk<TSchemaIO extends AbstractSchemaIO, TInput extends InputSchema<TSchemaIO[0]>> = TInput extends undefined ? undefined : TInput extends TSchemaIO[0] ? SchemaToSilk<TSchemaIO, TInput> : {
168
- [K in keyof TInput]: TInput[K] extends TSchemaIO[0] ? SchemaToSilk<TSchemaIO, TInput[K]> : never;
169
- };
170
- type InferInputI<TInput extends object | undefined, TSchemaIO extends AbstractSchemaIO> = TInput extends undefined ? undefined : TInput extends TSchemaIO[0] ? ObjectOrNever<InferSchemaI<TInput, TSchemaIO>> : {
171
- [K in keyof TInput]: InferSchemaI<TInput[K], TSchemaIO>;
172
- };
173
- type InferInputO<TInput extends object | undefined, TSchemaIO extends AbstractSchemaIO> = TInput extends undefined ? undefined : TInput extends TSchemaIO[0] ? ObjectOrNever<InferSchemaO<TInput, TSchemaIO>> : {
174
- [K in keyof TInput]: InferSchemaO<TInput[K], TSchemaIO>;
175
- };
176
- interface CallableInputParser<TSchema extends InputSchema<GraphQLSilk>> {
103
+ type InferInputI<TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined> = TInput extends undefined ? undefined : TInput extends GraphQLSilk ? StandardSchemaV1.InferInput<TInput> : TInput extends Record<string, GraphQLSilk> ? {
104
+ [K in keyof TInput]: StandardSchemaV1.InferInput<TInput[K]>;
105
+ } : undefined;
106
+ type InferInputO<TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined> = TInput extends undefined ? undefined : TInput extends GraphQLSilk ? StandardSchemaV1.InferOutput<TInput> : TInput extends Record<string, GraphQLSilk> ? {
107
+ [K in keyof TInput]: StandardSchemaV1.InferOutput<TInput[K]>;
108
+ } : never;
109
+ interface CallableInputParser<TSchema extends GraphQLSilk | Record<string, GraphQLSilk> | undefined> {
177
110
  /**
178
111
  * input schema
179
112
  */
@@ -181,84 +114,180 @@ interface CallableInputParser<TSchema extends InputSchema<GraphQLSilk>> {
181
114
  /**
182
115
  * Origin value to parse
183
116
  */
184
- value: InferInputI<TSchema, GraphQLSilkIO>;
117
+ value: InferInputI<TSchema>;
185
118
  /**
186
- * Parse the input and return the result
119
+ * Parse the input and return the standard result
187
120
  */
188
- (): Promise<StandardSchemaV1.Result<InferInputO<TSchema, GraphQLSilkIO>>>;
121
+ (): Promise<StandardSchemaV1.Result<InferInputO<TSchema>>>;
189
122
  /**
190
123
  * Result of parsing. Set it to `undefined` then the parser will run again.
191
124
  */
192
- result: StandardSchemaV1.Result<InferInputO<TSchema, GraphQLSilkIO>> | undefined;
125
+ result: StandardSchemaV1.Result<InferInputO<TSchema>> | undefined;
126
+ /**
127
+ * Parse the input and return the result
128
+ */
129
+ getResult(): Promise<InferInputO<TSchema>>;
193
130
  }
194
- declare function createInputParser<TSchema extends InputSchema<GraphQLSilk> | undefined>(schema: TSchema, value: InferInputI<TSchema, GraphQLSilkIO>): CallableInputParser<TSchema>;
195
- declare function parseInputValue<TSchema extends InputSchema<GraphQLSilk> | undefined>(inputSchema: TSchema, input: any): MayPromise<StandardSchemaV1.Result<InferInputO<TSchema, GraphQLSilkIO>>>;
131
+ declare function createInputParser<TSchema extends GraphQLSilk | Record<string, GraphQLSilk> | undefined>(schema: TSchema, value: InferInputI<TSchema>): CallableInputParser<TSchema>;
132
+ declare function parseInputValue<TSchema extends GraphQLSilk | Record<string, GraphQLSilk> | undefined>(inputSchema: TSchema, input: any): MayPromise<StandardSchemaV1.Result<InferInputO<TSchema>>>;
196
133
  declare function getStandardValue<T>(result: StandardSchemaV1.Result<T>): T;
197
134
  declare function getStandardValue<T>(result?: StandardSchemaV1.Result<T>): T | undefined;
198
135
  declare function getStandardValue<T>(result: StandardSchemaV1.Result<T> | null): T | null;
199
136
 
200
- interface IChainFactory<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined> {
137
+ interface IChainFactory<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> {
201
138
  description(description: GraphQLFieldOptions["description"]): this;
202
139
  deprecationReason(deprecationReason: GraphQLFieldOptions["deprecationReason"]): this;
203
140
  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>;
141
+ output<TOutputNew extends GraphQLSilk>(output: TOutputNew): IChainFactory<TOutputNew, TInput>;
142
+ input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): IChainFactory<TOutput, TInputNew>;
206
143
  }
207
- declare abstract class BaseChainFactory {
208
- protected readonly options?: Partial<FieldOrOperation<any, any, any, any> & {
209
- middlewares: Middleware[];
210
- }> | undefined;
144
+ interface ChainFactoryOptions extends FieldMeta {
145
+ middlewares?: Middleware[];
146
+ }
147
+ declare abstract class BaseChainFactory<TField extends BaseField = any> {
148
+ protected readonly options?: Partial<ChainFactoryOptions> | undefined;
211
149
  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;
150
+ description: (description: graphql_jsutils_Maybe.Maybe<string>) => BaseChainFactory<any>;
151
+ deprecationReason: (deprecationReason: graphql_jsutils_Maybe.Maybe<string>) => BaseChainFactory<any>;
152
+ extensions: (extensions: graphql_jsutils_Maybe.Maybe<Readonly<graphql.GraphQLFieldExtensions<any, any, any>>>) => BaseChainFactory<any>;
215
153
  };
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;
154
+ constructor(options?: Partial<ChainFactoryOptions> | undefined);
155
+ protected abstract clone(options?: Partial<ChainFactoryOptions>): this;
222
156
  description(description: GraphQLFieldOptions["description"]): this;
223
157
  deprecationReason(deprecationReason: GraphQLFieldOptions["deprecationReason"]): this;
224
158
  extensions(extensions: GraphQLFieldOptions["extensions"]): this;
225
- use(...middlewares: Middleware[]): this;
159
+ use(...middlewares: Middleware<TField>[]): this;
160
+ }
161
+ declare class FieldChainFactory<TOutput extends GraphQLSilk = never, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseChainFactory<Field<any, TOutput, TInput>> implements IChainFactory<TOutput, TInput> {
162
+ static methods(): FieldChainFactory<never, undefined>;
163
+ protected clone(options?: Partial<ChainFactoryOptions>): this;
164
+ output<TOutputNew extends GraphQLSilk>(output: TOutputNew): FieldChainFactory<TOutputNew, TInput>;
165
+ input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): FieldChainFactory<TOutput, TInputNew>;
166
+ resolve<TParent extends GraphQLSilk>(resolve: (parent: StandardSchemaV1.InferOutput<TParent>, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Field<TParent, TOutput, TInput>;
167
+ load<TParent extends GraphQLSilk>(resolve: (parents: StandardSchemaV1.InferOutput<TParent>[], input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>[]>): Field<TParent, TOutput, TInput>;
168
+ }
169
+ declare class QueryChainFactory<TOutput extends GraphQLSilk = never, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseChainFactory<Query<TOutput, TInput>> implements IChainFactory<TOutput, TInput> {
170
+ static methods(): QueryChainFactory<never, undefined>;
171
+ protected clone(options?: Partial<ChainFactoryOptions>): this;
172
+ output<TOutputNew extends GraphQLSilk>(output: TOutputNew): QueryChainFactory<TOutputNew, TInput>;
173
+ input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): QueryChainFactory<TOutput, TInputNew>;
174
+ resolve(resolve: (input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Query<TOutput, TInput>;
175
+ }
176
+ declare class MutationChainFactory<TOutput extends GraphQLSilk = never, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseChainFactory<Mutation<TOutput, TInput>> implements IChainFactory<TOutput, TInput> {
177
+ static methods(): MutationChainFactory<never, undefined>;
178
+ protected clone(options?: Partial<ChainFactoryOptions>): this;
179
+ output<TOutputNew extends GraphQLSilk>(output: TOutputNew): MutationChainFactory<TOutputNew, TInput>;
180
+ input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): MutationChainFactory<TOutput, TInputNew>;
181
+ resolve(resolve: (input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Mutation<TOutput, TInput>;
182
+ }
183
+ declare class SubscriptionChainFactory<TOutput extends GraphQLSilk = never, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseChainFactory<Subscription<TOutput, TInput, any>> implements IChainFactory<TOutput, TInput> {
184
+ static methods(): SubscriptionChainFactory<never, undefined>;
185
+ protected clone(options?: Partial<ChainFactoryOptions>): this;
186
+ output<TOutputNew extends GraphQLSilk>(output: TOutputNew): SubscriptionChainFactory<TOutputNew, TInput>;
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>;
189
+ }
190
+ interface ResolvableSubscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends Subscription<TOutput, TInput, TValue> {
191
+ resolve(resolve: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Subscription<TOutput, TInput, TValue>;
192
+ }
193
+ declare class QueryFactoryWithResolve<TInputO, TOutput extends GraphQLSilk, TInput extends GraphQLSilk<TInputO>> extends BaseChainFactory<Query<TOutput, TInput>> implements Query<TOutput, TInput> {
194
+ protected output: TOutput;
195
+ protected readonly options: QueryOptions<TOutput, TInput>;
196
+ get "~meta"(): Query<TOutput, TInput>["~meta"];
197
+ constructor(output: TOutput, options: QueryOptions<TOutput, TInput>);
198
+ protected clone(options?: Partial<typeof this.options> | undefined): this;
199
+ input<TInputNew extends GraphQLSilk<TInputO>>(input: TInputNew): QueryFactoryWithResolve<TInputO, TOutput, TInputNew>;
200
+ }
201
+ declare class MutationFactoryWithResolve<TInputO, TOutput extends GraphQLSilk, TInput extends GraphQLSilk<TInputO>> extends BaseChainFactory<Query<TOutput, TInput>> implements Mutation<TOutput, TInput> {
202
+ protected output: TOutput;
203
+ protected readonly options: MutationOptions<TOutput, TInput>;
204
+ get "~meta"(): Mutation<TOutput, TInput>["~meta"];
205
+ constructor(output: TOutput, options: MutationOptions<TOutput, TInput>);
206
+ protected clone(options?: Partial<typeof this.options> | undefined): this;
207
+ input<TInputNew extends GraphQLSilk<TInputO>>(input: TInputNew): MutationFactoryWithResolve<TInputO, TOutput, TInputNew>;
208
+ }
209
+ declare class FieldFactoryWithResolve<TParent extends GraphQLSilk, TOutput extends GraphQLSilk> extends BaseChainFactory<Field<TParent, TOutput, undefined>> {
210
+ protected output: TOutput;
211
+ protected readonly options: FieldOptions<TParent, TOutput, undefined>;
212
+ get "~meta"(): Field<TParent, TOutput, undefined>["~meta"];
213
+ constructor(output: TOutput, options: FieldOptions<TParent, TOutput, undefined>);
214
+ protected clone(options?: Partial<typeof this.options> | undefined): this;
215
+ }
216
+
217
+ interface FieldMeta extends GraphQLFieldOptions {
218
+ operation: "field" | "query" | "mutation" | "subscription";
219
+ output: GraphQLSilk;
220
+ input: GraphQLSilk | Record<string, GraphQLSilk> | undefined;
221
+ resolve: (...args: any) => MayPromise<any>;
222
+ }
223
+ interface BaseField {
224
+ readonly "~meta": FieldMeta;
225
+ }
226
+ interface Field<TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseField {
227
+ "~meta": {
228
+ operation: "field";
229
+ output: TOutput;
230
+ input: TInput;
231
+ types?: {
232
+ parent: ReSilk<TParent>;
233
+ };
234
+ resolve: (parent: StandardSchemaV1.InferOutput<NonNullable<TParent>>, input: InferInputI<TInput>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
235
+ } & GraphQLFieldOptions;
236
+ }
237
+ interface Query<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseField {
238
+ "~meta": {
239
+ operation: "query";
240
+ parent?: undefined;
241
+ output: TOutput;
242
+ input: TInput;
243
+ resolve: (input: InferInputI<TInput>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
244
+ } & GraphQLFieldOptions;
245
+ }
246
+ interface Mutation<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseField {
247
+ "~meta": {
248
+ operation: "mutation";
249
+ parent?: undefined;
250
+ output: TOutput;
251
+ input: TInput;
252
+ resolve: (input: InferInputI<TInput>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
253
+ } & GraphQLFieldOptions;
254
+ }
255
+ interface Subscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends BaseField {
256
+ "~meta": {
257
+ operation: "subscription";
258
+ parent?: undefined;
259
+ output: TOutput;
260
+ input: TInput;
261
+ types?: {
262
+ value: TValue;
263
+ } & GraphQLFieldOptions;
264
+ resolve: (value: TValue, input: InferInputI<TInput>, options?: ResolvingOptions) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
265
+ subscribe: (input: InferInputI<TInput>, options?: ResolvingOptions) => MayPromise<AsyncIterator<TValue>>;
266
+ } & GraphQLFieldOptions;
267
+ }
268
+ interface Resolver {
269
+ readonly "~meta": {
270
+ [IS_RESOLVER]: true;
271
+ fields: Record<string, BaseField | typeof FIELD_HIDDEN>;
272
+ options?: ResolverOptionsWithExtensions<any>;
273
+ parent?: GraphQLSilk;
274
+ };
226
275
  }
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>>): FieldOrOperation<any, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "query">;
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>>): FieldOrOperation<any, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "mutation">;
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>;
276
+ type Operation = Query<GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> | Mutation<GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> | Subscription<GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined, any>;
277
+ type FieldOrOperation = Field<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> | Operation;
278
+ type ReSilk<T extends GraphQLSilk> = GraphQLSilk<NonNullable<T["~standard"]["types"]>["output"], NonNullable<T["~standard"]["types"]>["input"]>;
279
+
280
+ type typesLoom_BaseField = BaseField;
281
+ type typesLoom_Field<TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> = Field<TParent, TOutput, TInput>;
282
+ type typesLoom_FieldMeta = FieldMeta;
283
+ type typesLoom_FieldOrOperation = FieldOrOperation;
284
+ type typesLoom_Mutation<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> = Mutation<TOutput, TInput>;
285
+ type typesLoom_Operation = Operation;
286
+ type typesLoom_Query<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> = Query<TOutput, TInput>;
287
+ type typesLoom_Resolver = Resolver;
288
+ type typesLoom_Subscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> = Subscription<TOutput, TInput, TValue>;
289
+ declare namespace typesLoom {
290
+ export type { typesLoom_BaseField as BaseField, typesLoom_Field as Field, typesLoom_FieldMeta as FieldMeta, typesLoom_FieldOrOperation as FieldOrOperation, typesLoom_Mutation as Mutation, typesLoom_Operation as Operation, typesLoom_Query as Query, typesLoom_Resolver as Resolver, typesLoom_Subscription as Subscription };
262
291
  }
263
292
 
264
293
  interface GraphQLSilk<TOutput = any, TInput = any> extends StandardSchemaV1<TInput, TOutput> {
@@ -267,26 +296,13 @@ interface GraphQLSilk<TOutput = any, TInput = any> extends StandardSchemaV1<TInp
267
296
  */
268
297
  [GET_GRAPHQL_TYPE]?: () => GraphQLOutputType;
269
298
  }
270
- type AbstractSchemaIO = [
271
- baseSchema: object,
272
- inputPath: string,
273
- outputPath: string
274
- ];
275
- type GraphQLSilkIO = [
276
- object: GraphQLSilk,
277
- input: "~standard.types.input",
278
- output: "~standard.types.output"
279
- ];
280
- type InferSchemaI<TSchema, TSchemaIO extends AbstractSchemaIO> = InferPropertyType<TSchema, TSchemaIO[1]>;
281
- type InferSchemaO<TSchema, TSchemaIO extends AbstractSchemaIO> = InferPropertyType<TSchema, TSchemaIO[2]>;
282
- type SchemaToSilk<TSchemaIO extends AbstractSchemaIO, TSchema extends TSchemaIO[0]> = GraphQLSilk<InferSchemaO<TSchema, TSchemaIO>, InferSchemaI<TSchema, TSchemaIO>>;
283
- interface ResolverOptions<TField extends GenericFieldOrOperation = GenericFieldOrOperation> {
299
+ interface ResolverOptions<TField extends FieldOrOperation = FieldOrOperation> {
284
300
  middlewares?: Middleware<TField>[];
285
301
  }
286
- interface ResolverOptionsWithExtensions<TField extends GenericFieldOrOperation = GenericFieldOrOperation> extends ResolverOptions<TField>, Pick<GraphQLObjectTypeConfig<any, any>, "extensions"> {
302
+ interface ResolverOptionsWithExtensions<TField extends FieldOrOperation = FieldOrOperation> extends ResolverOptions<TField>, Pick<GraphQLObjectTypeConfig<any, any>, "extensions"> {
287
303
  }
288
- interface ResolverOptionsWithParent<TField extends GenericFieldOrOperation = GenericFieldOrOperation> extends ResolverOptionsWithExtensions<TField> {
289
- parent?: TField extends FieldOrOperation<infer TParent, any, any, any> ? TParent : undefined;
304
+ interface ResolverOptionsWithParent<TField extends FieldOrOperation = FieldOrOperation> extends ResolverOptionsWithExtensions<TField> {
305
+ parent?: TField extends Field<infer TParent, any, any> ? TParent : undefined;
290
306
  }
291
307
  interface ResolvingOptions extends Pick<ResolverOptions, "middlewares"> {
292
308
  }
@@ -294,121 +310,213 @@ type OperationType = "query" | "mutation" | "subscription";
294
310
  type FieldOrOperationType = "field" | OperationType;
295
311
  interface GraphQLFieldOptions extends Pick<GraphQLFieldConfig<any, any>, "description" | "deprecationReason" | "extensions"> {
296
312
  }
313
+ type InferFieldInput<TField extends BaseField> = TField["~meta"]["input"];
314
+ type InferFieldOutput<TField extends BaseField> = TField["~meta"]["output"];
297
315
  /**
298
- * Operation or Field for resolver.
316
+ * Options for creating a GraphQL Query.
299
317
  */
300
- interface FieldOrOperation<TParent extends undefined | GraphQLSilk, TOutput extends GraphQLSilk, TInput extends InputSchema<GraphQLSilk> | undefined = undefined, TType extends FieldOrOperationType = FieldOrOperationType> extends GraphQLFieldOptions {
301
- type: TType;
302
- input: TInput;
303
- output: TOutput;
304
- resolve: TType extends "field" ? (parent: StandardSchemaV1.InferOutput<NonNullable<TParent>>, input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>> : TType extends "subscription" ? (value: any, input: InferInputI<TInput, GraphQLSilkIO>) => Promise<StandardSchemaV1.InferOutput<TOutput>> : (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
305
- subscribe?: TType extends "subscription" ? (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => MayPromise<AsyncIterator<any>> : undefined;
318
+ interface QueryOptions<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends ResolverOptions<Query<TOutput, TInput>>, GraphQLFieldOptions {
319
+ input?: TInput;
320
+ resolve: (input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
306
321
  }
307
- type GenericFieldOrOperation = FieldOrOperation<any, any, any, any>;
308
- type InferFieldParent<TField extends GenericFieldOrOperation> = TField extends FieldOrOperation<infer TParent, any, any, any> ? TParent : never;
309
- type InferFieldInput<TField extends GenericFieldOrOperation> = TField extends FieldOrOperation<any, any, infer TInput, any> ? TInput : never;
310
- type InferFieldOutput<TField extends GenericFieldOrOperation> = TField extends FieldOrOperation<any, infer TOutput, any, any> ? TOutput : never;
311
322
  /**
312
- * Options for creating a GraphQL Query or Mutation.
323
+ * Options for creating a GraphQL Mutation.
313
324
  */
314
- interface QueryMutationOptions<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined> extends ResolverOptions<FieldOrOperation<undefined, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "query" | "mutation">>, GraphQLFieldOptions {
325
+ interface MutationOptions<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends ResolverOptions<Mutation<TOutput, TInput>>, GraphQLFieldOptions {
315
326
  input?: TInput;
316
- resolve: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>;
327
+ resolve: (input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
317
328
  }
318
329
  /**
319
330
  * Function to create a GraphQL query.
320
331
  */
321
- interface QueryFactory<TSchemaIO extends AbstractSchemaIO> {
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>;
332
+ interface QueryFactory {
333
+ <TOutput extends GraphQLSilk>(output: TOutput, resolve: () => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Query<TOutput, undefined>;
334
+ <TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined>(output: TOutput, options: QueryOptions<TOutput, TInput>): Query<TOutput, TInput>;
335
+ <TOutput extends GraphQLSilk>(output: TOutput): QueryChainFactory<TOutput, undefined>;
324
336
  }
325
- interface QueryFactoryWithChain<TSchemaIO extends AbstractSchemaIO> extends QueryFactory<TSchemaIO>, QueryChainFactory<TSchemaIO, never, undefined> {
337
+ interface QueryFactoryWithChain extends QueryFactory, QueryChainFactory<never, undefined> {
326
338
  }
327
339
  /**
328
340
  * Function to create a GraphQL mutation.
329
341
  */
330
- interface MutationFactory<TSchemaIO extends AbstractSchemaIO> {
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>;
342
+ interface MutationFactory {
343
+ <TOutput extends GraphQLSilk>(output: TOutput, resolve: () => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Mutation<TOutput, undefined>;
344
+ <TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined>(output: TOutput, options: MutationOptions<TOutput, TInput>): Mutation<TOutput, TInput>;
345
+ <TOutput extends GraphQLSilk>(output: TOutput): MutationChainFactory<TOutput, undefined>;
333
346
  }
334
347
  /**
335
348
  * Function to create a GraphQL mutation.
336
349
  */
337
- interface MutationFactoryWithChain<TSchemaIO extends AbstractSchemaIO> extends MutationFactory<TSchemaIO>, MutationChainFactory<TSchemaIO, never, undefined> {
350
+ interface MutationFactoryWithChain extends MutationFactory, MutationChainFactory<never, undefined> {
338
351
  }
339
352
  /**
340
353
  * Options for External Filed of existing GraphQL Object.
341
354
  */
342
- interface FieldOptions<TSchemaIO extends AbstractSchemaIO, TParent extends TSchemaIO[0], TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined> extends ResolverOptions<FieldOrOperation<SchemaToSilk<TSchemaIO, TParent>, SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, "field">>, GraphQLFieldOptions {
355
+ interface FieldOptions<TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends ResolverOptions<Field<TParent, TOutput, TInput>>, GraphQLFieldOptions {
343
356
  input?: TInput;
344
- resolve: (parent: InferSchemaO<TParent, TSchemaIO>, input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>;
357
+ resolve: (parent: StandardSchemaV1.InferOutput<TParent>, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
345
358
  }
346
359
  /**
347
360
  * Function to create a GraphQL Field.
348
361
  */
349
- interface FieldFactory<TSchemaIO extends AbstractSchemaIO> {
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>;
362
+ interface FieldFactory {
363
+ <TParent extends GraphQLSilk, TOutput extends GraphQLSilk>(output: TOutput, resolve: (parent: StandardSchemaV1.InferOutput<TParent>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Field<TParent, TOutput, undefined>;
364
+ <TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined>(output: TOutput, options: FieldOptions<TParent, TOutput, TInput>): Field<TParent, TOutput, TInput>;
365
+ <TOutput extends GraphQLSilk>(output: TOutput): FieldChainFactory<TOutput, undefined>;
352
366
  }
353
- interface FieldFactoryWithUtils<TSchemaIO extends AbstractSchemaIO> extends FieldFactory<TSchemaIO>, FieldChainFactory<TSchemaIO, never, undefined> {
367
+ interface FieldFactoryWithUtils extends FieldFactory, FieldChainFactory<never, undefined> {
354
368
  /** Set fields to be hidden in GraphQL Schema */
355
369
  hidden: typeof FIELD_HIDDEN;
356
370
  }
357
371
  /**
358
372
  * Options for creating a GraphQL Subscription.
359
373
  */
360
- interface SubscriptionOptions<TSchemaIO extends AbstractSchemaIO, TOutput extends TSchemaIO[0], TInput extends InputSchema<TSchemaIO[0]> = undefined, TValue = InferSchemaO<TOutput, TSchemaIO>> extends ResolverOptions<Subscription<SchemaToSilk<TSchemaIO, TOutput>, InputSchemaToSilk<TSchemaIO, TInput>, TValue>>, GraphQLFieldOptions {
374
+ interface SubscriptionOptions<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends ResolverOptions<Subscription<TOutput, TInput, TValue>>, GraphQLFieldOptions {
361
375
  input?: TInput;
362
- subscribe: (input: InferInputO<TInput, TSchemaIO>) => MayPromise<AsyncIterator<TValue>>;
363
- resolve?: (value: TValue, input: InferInputO<TInput, TSchemaIO>) => MayPromise<InferSchemaO<TOutput, TSchemaIO>>;
364
- }
365
- interface Subscription<TOutput extends GraphQLSilk, TInput extends InputSchema<GraphQLSilk> = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends FieldOrOperation<undefined, TOutput, TInput, "subscription"> {
366
- resolve: (value: TValue, input: InferInputI<TInput, GraphQLSilkIO>) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
367
- subscribe: (input: InferInputI<TInput, GraphQLSilkIO>, options?: ResolvingOptions) => MayPromise<AsyncIterator<TValue>>;
376
+ subscribe: (input: InferInputO<TInput>) => MayPromise<AsyncIterator<TValue>>;
377
+ resolve?: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
368
378
  }
369
379
  /**
370
380
  * Function to create a GraphQL subscription.
371
381
  */
372
- interface SubscriptionFactory<TSchemaIO extends AbstractSchemaIO> {
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> {
382
+ interface SubscriptionFactory {
383
+ <TOutput extends GraphQLSilk, TValue = StandardSchemaV1.InferOutput<TOutput>>(output: TOutput, subscribe: () => MayPromise<AsyncIterator<StandardSchemaV1.InferOutput<TOutput>>>): Subscription<TOutput, undefined, TValue>;
384
+ <TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>>(output: TOutput, options: SubscriptionOptions<TOutput, TInput, TValue>): Subscription<TOutput, TInput, TValue>;
385
+ <TOutput extends GraphQLSilk>(output: TOutput): SubscriptionChainFactory<TOutput, undefined>;
377
386
  }
378
- interface ResolverFactory<TSchemaIO extends AbstractSchemaIO> {
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;
380
- <TOperations extends Record<string, FieldOrOperation<undefined, any, any, OperationType>>>(operations: TOperations, options?: ResolverOptions<ValueOf<TOperations>>): TOperations;
387
+ interface SubscriptionFactoryWithChain extends SubscriptionFactory, SubscriptionChainFactory<never, undefined> {
381
388
  }
382
- type OmitInUnion<TUnion, TOmit> = TUnion extends infer T ? T extends TOmit ? never : T : never;
383
389
 
384
- 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>;
385
- declare function getSubscriptionOptions(subscribeOrOptions: (() => any) | SubscriptionOptions<any, any, any, any>): SubscriptionOptions<any, any, any, any>;
390
+ declare function getOperationOptions(resolveOrOptions: ((...args: any) => any) | FieldOptions<any, any, any> | QueryOptions<any, any> | MutationOptions<any, any>): any;
391
+ declare function getSubscriptionOptions(subscribeOrOptions: (() => any) | SubscriptionOptions<any, any, any>): SubscriptionOptions<any, any, any>;
386
392
  declare function getFieldOptions({ description, deprecationReason, extensions, }: GraphQLFieldOptions): GraphQLFieldOptions;
387
393
 
388
- interface MiddlewareOptions<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>> {
394
+ /**
395
+ * Create a Silk from Scalar.
396
+ */
397
+ declare function silk<TScalar extends GraphQLVariants<GraphQLScalarType>>(type: TScalar | (() => TScalar), validate?: (value: InferScalarExternalByVariants<TScalar>) => StandardSchemaV1.Result<InferScalarExternalByVariants<TScalar>> | Promise<StandardSchemaV1.Result<InferScalarInternalByVariants<TScalar>>>): GraphQLSilk<InferScalarInternalByVariants<TScalar>, InferScalarInternalByVariants<TScalar>>;
398
+ /**
399
+ * Create a GraphQLSilk Object.
400
+ */
401
+ declare function silk<TObject extends GraphQLVariants<GraphQLObjectType>>(type: TObject | (() => TObject), validate?: (value: InferObjectSourceByVariants<TObject>) => StandardSchemaV1.Result<InferObjectSourceByVariants<TObject>> | Promise<StandardSchemaV1.Result<InferObjectSourceByVariants<TObject>>>): GraphQLSilk<InferObjectSourceByVariants<TObject>, InferObjectSourceByVariants<TObject>>;
402
+ /**
403
+ * Create a GraphQLSilk Object.
404
+ */
405
+ declare function silk<TOutput, TInput = TOutput>(type: GraphQLOutputType | (() => GraphQLOutputType), validate?: (value: TInput) => StandardSchemaV1.Result<TOutput> | Promise<StandardSchemaV1.Result<TOutput>>): GraphQLSilk<TOutput, TInput>;
406
+ declare namespace silk {
407
+ var parse: typeof parseSilk;
408
+ var getType: typeof getGraphQLType;
409
+ var nonNull: typeof nonNullSilk;
410
+ var list: typeof listSilk;
411
+ var nullable: typeof nullableSilk;
412
+ }
413
+ type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<StandardSchemaV1.InferOutput<TSilk>>, NonNullable<StandardSchemaV1.InferInput<TSilk>>>;
414
+ /**
415
+ * Non-nullable Silk.
416
+ */
417
+ declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
418
+ type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<EnsureArray<StandardSchemaV1.InferOutput<TSilk>>, EnsureArray<StandardSchemaV1.InferOutput<TSilk>>>;
419
+ /**
420
+ * List Silk.
421
+ */
422
+ declare function listSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): ListSilk<TSilk>;
423
+ type NullableSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<StandardSchemaV1.InferOutput<TSilk> | null | undefined, StandardSchemaV1.InferInput<TSilk>>;
424
+ /**
425
+ * Nullable Silk.
426
+ */
427
+ declare function nullableSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NullableSilk<TSilk>;
428
+ /**
429
+ * Get GraphQL Output Type from Silk.
430
+ * @param silk GraphQL Silk
431
+ * @returns GraphQL Output Type
432
+ */
433
+ declare function getGraphQLType(silk: GraphQLSilk): GraphQLOutputType;
434
+ /**
435
+ * Validate and transform input to output
436
+ * @param silk silk GraphQL Silk
437
+ * @param input
438
+ * @returns output
439
+ */
440
+ declare function parseSilk<TSilk extends GraphQLSilk>(silk: TSilk, input: StandardSchemaV1.InferInput<TSilk>): MayPromise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSilk>>>;
441
+ declare function isSilk(target: any): target is GraphQLSilk;
442
+ type GraphQLVariants<TSource extends GraphQLNullableType> = TSource | GraphQLList<TSource> | GraphQLList<GraphQLNonNull<TSource>> | GraphQLNonNull<TSource> | GraphQLNonNull<GraphQLList<TSource>> | GraphQLNonNull<GraphQLList<GraphQLNonNull<TSource>>>;
443
+ type InferScalarInternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarInternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarInternalByVariants<U>[] : never : T extends GraphQLScalarType<infer TInternal, any> ? TInternal | null | undefined : never;
444
+ type InferScalarExternalByVariants<T extends GraphQLVariants<GraphQLScalarType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? NonNullable<InferScalarExternalByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLScalarType> ? InferScalarExternalByVariants<U>[] : never : T extends GraphQLScalarType<any, infer TExternal> ? TExternal | null | undefined : never;
445
+ type InferObjectSourceByVariants<T extends GraphQLVariants<GraphQLObjectType>> = T extends GraphQLNonNull<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? NonNullable<InferObjectSourceByVariants<U>> : never : T extends GraphQLList<infer U> ? U extends GraphQLVariants<GraphQLObjectType> ? InferObjectSourceByVariants<U>[] : never : T extends GraphQLObjectType<infer TSource> ? TSource | null | undefined : never;
446
+ type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
447
+
448
+ declare const createQuery: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => MayPromise<unknown>) | QueryOptions<any, any>) => Query<any, any> | QueryChainFactory<never, undefined>;
449
+ declare const query: QueryFactoryWithChain;
450
+ declare const createMutation: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => MayPromise<unknown>) | MutationOptions<any, any>) => Mutation<any, any> | MutationChainFactory<never, undefined>;
451
+ declare const mutation: MutationFactoryWithChain;
452
+ declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: FieldOptions<any, any, any> | ((parent: unknown) => unknown) | undefined) => Field<any, any, any> | FieldChainFactory<never, undefined>;
453
+ declare const field: FieldFactoryWithUtils;
454
+ declare const defaultSubscriptionResolve: (source: any) => any;
455
+ declare function createSubscription(output: GraphQLSilk<any, any>): SubscriptionChainFactory;
456
+ declare function createSubscription(output: GraphQLSilk<any, any>, subscribeOrOptions: (() => MayPromise<AsyncIterator<unknown>>) | SubscriptionOptions<any, any, any>): Subscription<any, any, any>;
457
+ declare const subscription: SubscriptionFactoryWithChain;
458
+ declare const resolver: ResolverFactory;
459
+ declare const loom: {
460
+ query: QueryFactoryWithChain;
461
+ resolver: ResolverFactory;
462
+ field: FieldFactoryWithUtils;
463
+ subscription: SubscriptionFactoryWithChain;
464
+ mutation: MutationFactoryWithChain;
465
+ };
466
+ interface ResolverFactory {
467
+ of<TParent extends GraphQLSilk, TFields extends Record<string, Field<TParent, any, any> | Operation | typeof FIELD_HIDDEN>>(parent: TParent, fields: TFields, options?: ResolverOptionsWithExtensions<OmitInUnion<ValueOf<TFields>, typeof FIELD_HIDDEN>>): ObjectChainResolver<TParent, TFields>;
468
+ <TFields extends Record<string, Operation>>(operations: TFields, options?: ResolverOptions<ValueOf<TFields>>): ChainResolver<TFields>;
469
+ }
470
+ declare class ChainResolver<TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> implements Resolver {
471
+ protected meta: {
472
+ [IS_RESOLVER]: true;
473
+ fields: TFields;
474
+ options?: ResolverOptionsWithExtensions;
475
+ };
476
+ constructor(fields: TFields, options?: ResolverOptionsWithExtensions<any>);
477
+ get "~meta"(): typeof this.meta;
478
+ use(...middlewares: Middleware<OmitInUnion<ValueOf<TFields>, typeof FIELD_HIDDEN>>[]): this;
479
+ toExecutor(): Executor<TFields>;
480
+ }
481
+ declare class ObjectChainResolver<TParent extends GraphQLSilk, TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> extends ChainResolver<TFields> {
482
+ protected meta: {
483
+ [IS_RESOLVER]: true;
484
+ fields: TFields;
485
+ parent: TParent;
486
+ options?: ResolverOptionsWithExtensions;
487
+ };
488
+ constructor(parent: TParent, fields: TFields, options?: ResolverOptionsWithExtensions<any>);
489
+ get "~meta"(): typeof this.meta;
490
+ extensions(extensions: Pick<GraphQLObjectTypeConfig<any, any>, "extensions">["extensions"]): this;
491
+ }
492
+ type Executor<TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> = {
493
+ [K in keyof TFields]: TFields[K] extends FieldOrOperation ? TFields[K]["~meta"]["resolve"] : never;
494
+ };
495
+
496
+ interface MiddlewareOptions<TField extends BaseField = BaseField> {
389
497
  /** The Output Silk of the field */
390
498
  outputSilk: StandardSchemaV1.InferOutput<InferFieldOutput<TField>>;
391
499
  /** The previous object, which for a field on the root Query type is often not used. */
392
- parent: TField extends FieldOrOperation<infer TParent, any, any, any> ? TParent extends undefined ? undefined : StandardSchemaV1.InferOutput<NonNullable<TParent>> : never;
500
+ parent: TField extends Field<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> ? StandardSchemaV1.InferOutput<NonNullable<TField["~meta"]["types"]>["parent"]> : undefined;
393
501
  /** A function to parse the input of the field */
394
- parseInput: TField extends FieldOrOperation<any, any, infer TInput, any> ? CallableInputParser<TInput> : undefined;
395
- /** The type of the field: `query`, `mutation`, `subscription` or `field` */
396
- type: FieldOrOperationType;
502
+ parseInput: CallableInputParser<TField["~meta"]["input"]>;
503
+ /** The operation of the field: `query`, `mutation`, `subscription` or `field` */
504
+ operation: BaseField["~meta"]["operation"];
397
505
  }
398
- interface CallableMiddlewareOptions<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>> extends MiddlewareOptions<TField> {
506
+ interface CallableMiddlewareOptions<TField extends BaseField = BaseField> extends MiddlewareOptions<TField> {
399
507
  /** The function to call next in the middleware chain. */
400
508
  next: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
401
509
  /** The function to call next in the middleware chain. */
402
510
  (): MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
403
511
  }
404
- type Middleware<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>> = (options: CallableMiddlewareOptions<TField>) => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
405
- declare function applyMiddlewares<TField extends GenericFieldOrOperation = FieldOrOperation<any, any, any, any>>(middlewares: Middleware[], resolveFunction: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>, options: MiddlewareOptions<TField>): Promise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
512
+ type Middleware<TField extends BaseField = any> = (options: CallableMiddlewareOptions<TField>) => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
513
+ declare function applyMiddlewares<TField extends BaseField = BaseField>(middlewares: Middleware[], resolveFunction: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>, options: MiddlewareOptions<TField>): Promise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
406
514
  declare function compose<T>(...lists: (T[] | undefined)[]): T[];
407
515
 
408
516
  /**
409
517
  * Detailed payload of the current resolver
410
518
  */
411
- interface ResolverPayload<TContext extends object = object, TField extends FieldOrOperation<any, any, any, any> = FieldOrOperation<any, any, any, any>> {
519
+ interface ResolverPayload<TContext extends object = object, TField extends BaseField = BaseField> {
412
520
  /**
413
521
  * The previous object, which for a field on the root Query type is often not used.
414
522
  */
@@ -446,7 +554,7 @@ declare function isOnlyMemoryPayload(payload: ResolverPayload | OnlyMemoizationP
446
554
  /**
447
555
  * the AsyncLocalStorage instance to store the resolver payload
448
556
  */
449
- declare const resolverPayloadStorage: AsyncLocalStorage<OnlyMemoizationPayload | ResolverPayload<object, FieldOrOperation<any, any, any, any>>>;
557
+ declare const resolverPayloadStorage: AsyncLocalStorage<ResolverPayload<object, BaseField> | OnlyMemoizationPayload>;
450
558
  /**
451
559
  * use detailed payload of the current resolver
452
560
  * @returns the resolver payload
@@ -521,6 +629,20 @@ declare namespace mapValue {
521
629
  declare function toObjMap<T>(obj: Maybe<ReadOnlyObjMapLike<T>>): ReadOnlyObjMap<T>;
522
630
  declare function notNullish<T>(x: T | undefined | null): x is T;
523
631
  declare function deepMerge<T extends Record<string, any>>(...objects: (T | null | undefined)[]): T;
632
+ /**
633
+ * Wraps the provided data in an object with a single key `"~meta"`.
634
+ *
635
+ * @template T - The type of the data to be wrapped.
636
+ * @param {T} data - The data to be wrapped.
637
+ * @returns {{ "~meta": T }} - An object with a single key `"~meta"` containing the provided data.
638
+ * @example
639
+ * const originalData = { key: "value" };
640
+ * const metaData = meta(originalData);
641
+ * console.log(metaData); // Output: { "~meta": { key: "value" } }
642
+ */
643
+ declare function meta<T>(data: T): {
644
+ "~meta": T;
645
+ };
524
646
  type Maybe<T> = null | undefined | T;
525
647
  type ReadOnlyObjMapLike<T> = ReadOnlyObjMap<T> | {
526
648
  readonly [key: string]: T;
@@ -565,87 +687,6 @@ declare class EasyDataLoader<TKey, TData> {
565
687
  static nextTick(): Promise<void>;
566
688
  }
567
689
 
568
- /**
569
- * Create a Silk from Scalar.
570
- */
571
- declare function silk<TScalar extends GraphQLScalarType>(type: TScalar | (() => TScalar), parse?: (value: InferScalarExternal<TScalar>) => StandardSchemaV1.Result<InferScalarExternal<TScalar>> | Promise<StandardSchemaV1.Result<InferScalarInternal<TScalar>>>): GraphQLSilk<InferScalarInternal<TScalar> | undefined, InferScalarInternal<TScalar> | undefined>;
572
- /**
573
- * Create a GraphQLSilk Object.
574
- */
575
- declare function silk<TOutput, TInput = TOutput>(type: GraphQLOutputType | (() => GraphQLOutputType), validate?: (value: TInput) => StandardSchemaV1.Result<TOutput> | Promise<StandardSchemaV1.Result<TOutput>>): GraphQLSilk<TOutput, TInput>;
576
- declare namespace silk {
577
- var parse: typeof parseSilk;
578
- var getType: typeof getGraphQLType;
579
- var nonNull: typeof nonNullSilk;
580
- var list: typeof listSilk;
581
- var nullable: typeof nullableSilk;
582
- }
583
- type NonNullSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<NonNullable<StandardSchemaV1.InferOutput<TSilk>>, NonNullable<StandardSchemaV1.InferInput<TSilk>>>;
584
- /**
585
- * Non-nullable Silk.
586
- */
587
- declare function nonNullSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NonNullSilk<TSilk>;
588
- type ListSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<EnsureArray<StandardSchemaV1.InferOutput<TSilk>>, EnsureArray<StandardSchemaV1.InferOutput<TSilk>>>;
589
- /**
590
- * List Silk.
591
- */
592
- declare function listSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): ListSilk<TSilk>;
593
- type NullableSilk<TSilk extends GraphQLSilk<any, any>> = GraphQLSilk<StandardSchemaV1.InferOutput<TSilk> | null | undefined, StandardSchemaV1.InferInput<TSilk>>;
594
- /**
595
- * Nullable Silk.
596
- */
597
- declare function nullableSilk<TSilk extends GraphQLSilk<any, any>>(origin: TSilk): NullableSilk<TSilk>;
598
- /**
599
- * Get GraphQL Output Type from Silk.
600
- * @param silk GraphQL Silk
601
- * @returns GraphQL Output Type
602
- */
603
- declare function getGraphQLType(silk: GraphQLSilk): GraphQLOutputType;
604
- /**
605
- * Validate and transform input to output
606
- * @param silk silk GraphQL Silk
607
- * @param input
608
- * @returns output
609
- */
610
- declare function parseSilk<TSilk extends GraphQLSilk>(silk: TSilk, input: StandardSchemaV1.InferInput<TSilk>): MayPromise<StandardSchemaV1.Result<StandardSchemaV1.InferOutput<TSilk>>>;
611
- declare function isSilk(target: any): target is GraphQLSilk;
612
- type InferScalarInternal<T extends GraphQLScalarType> = T extends GraphQLScalarType<infer TInternal> ? TInternal : never;
613
- type InferScalarExternal<T extends GraphQLScalarType> = T extends GraphQLScalarType<any, infer TExternal> ? TExternal : never;
614
- type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
615
-
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">;
621
- declare const field: FieldFactoryWithUtils<GraphQLSilkIO>;
622
- declare const defaultSubscriptionResolve: (source: any) => any;
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>;
625
- declare const ResolverOptionsMap: WeakMap<object, ResolverOptionsWithParent<GenericFieldOrOperation>>;
626
- declare function baseResolver(operations: Record<string, FieldOrOperation<any, any, any>>, options: ResolverOptionsWithParent | undefined): Record<string, FieldOrOperation<any, any, any, FieldOrOperationType>>;
627
- declare const resolver: ResolverFactory<GraphQLSilkIO>;
628
- declare const loom: {
629
- query: QueryFactoryWithChain<GraphQLSilkIO>;
630
- resolver: ResolverFactory<GraphQLSilkIO>;
631
- field: FieldFactoryWithUtils<GraphQLSilkIO>;
632
- subscription: SubscriptionFactoryWithChain<GraphQLSilkIO>;
633
- mutation: MutationFactoryWithChain<GraphQLSilkIO>;
634
- };
635
-
636
- declare function createResolverFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk): ResolverFactory<TSchemaIO>;
637
- declare function createFieldFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): FieldFactoryWithUtils<TSchemaIO>;
638
- declare function createQueryFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): QueryFactory<TSchemaIO>;
639
- declare function createMutationFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): MutationFactory<TSchemaIO>;
640
- declare function createSubscriptionFactory<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): SubscriptionFactory<TSchemaIO>;
641
- declare function createLoom<TSchemaIO extends AbstractSchemaIO>(toSilk: (schema: TSchemaIO[0]) => GraphQLSilk, isSchema: (schema: InputSchema<TSchemaIO[0]>) => boolean): {
642
- query: QueryFactory<TSchemaIO>;
643
- mutation: MutationFactory<TSchemaIO>;
644
- field: FieldFactoryWithUtils<TSchemaIO>;
645
- resolver: ResolverFactory<TSchemaIO>;
646
- subscription: SubscriptionFactory<TSchemaIO>;
647
- };
648
-
649
690
  interface SchemaWeaver {
650
691
  vendor: string;
651
692
  getGraphQLType: (schema: any) => GraphQLOutputType;
@@ -676,7 +717,7 @@ declare function initWeaverContext(): WeaverContext;
676
717
  declare namespace initWeaverContext {
677
718
  var increasingID: number;
678
719
  }
679
- type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "getNamedType" | "memoNamedType";
720
+ type GlobalContextRequiredKeys = "names" | "getConfig" | "setConfig" | "deleteConfig" | "getNamedType" | "memoNamedType";
680
721
  interface GlobalWeaverContext extends Partial<Omit<WeaverContext, GlobalContextRequiredKeys>>, Pick<WeaverContext, GlobalContextRequiredKeys> {
681
722
  value?: WeaverContext;
682
723
  useConfig<TConfig extends WeaverConfig, TCallback extends () => any>(config: TConfig, callback: TCallback): ReturnType<TCallback>;
@@ -704,21 +745,8 @@ declare function collectNames<TRecords extends Record<string, object>[]>(...name
704
745
  declare function collectName<TSchema extends object>(name: string, schema: TSchema): TSchema;
705
746
  type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
706
747
 
707
- type SilkFieldOrOperation = FieldOrOperation<any, any, any, any>;
708
- interface FieldConvertOptions {
709
- optionsForResolving?: ResolvingOptions;
710
- }
711
- type SilkResolver = Record<string, FieldOrOperation<any, any, any, any> | typeof FIELD_HIDDEN>;
712
- interface CoreSchemaWeaverConfigOptions extends GraphQLSchemaConfig {
713
- getInputObjectName?: (name: string) => string;
714
- weaverContext?: WeaverContext;
715
- }
716
- interface CoreSchemaWeaverConfig extends WeaverConfig, CoreSchemaWeaverConfigOptions {
717
- [WEAVER_CONFIG]: "gqloom.core.schema";
718
- }
719
-
720
748
  declare class LoomObjectType extends GraphQLObjectType {
721
- protected extraFields: Map<string, SilkFieldOrOperation>;
749
+ protected extraFields: Map<string, BaseField>;
722
750
  protected hiddenFields: Set<string>;
723
751
  static AUTO_ALIASING: "__gqloom_auto_aliasing";
724
752
  protected weaverContext: WeaverContext;
@@ -733,14 +761,14 @@ declare class LoomObjectType extends GraphQLObjectType {
733
761
  addAlias(name: string): void;
734
762
  protected renameByAliases(): void;
735
763
  hideField(name: string): void;
736
- addField(name: string, resolver: SilkFieldOrOperation): void;
764
+ addField(name: string, resolver: BaseField): void;
737
765
  mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
738
766
  private extraFieldMap?;
739
767
  getFields(): GraphQLFieldMap<any, any>;
740
- protected mapToFieldConfig(map: Map<string, SilkFieldOrOperation>): Record<string, GraphQLFieldConfig<any, any>>;
741
- toFieldConfig(field: SilkFieldOrOperation, fieldName?: string): GraphQLFieldConfig<any, any>;
742
- protected provideForResolve(field: SilkFieldOrOperation): Pick<GraphQLFieldConfig<any, any>, "resolve"> | undefined;
743
- protected provideForSubscribe(field: SilkFieldOrOperation): Pick<GraphQLFieldConfig<any, any>, "subscribe"> | undefined;
768
+ protected mapToFieldConfig(map: Map<string, BaseField>): Record<string, GraphQLFieldConfig<any, any>>;
769
+ toFieldConfig(field: BaseField, fieldName?: string): GraphQLFieldConfig<any, any>;
770
+ protected provideForResolve(field: BaseField): Pick<GraphQLFieldConfig<any, any>, "resolve"> | undefined;
771
+ protected provideForSubscribe(field: BaseField | Subscription<any, any, any>): Pick<GraphQLFieldConfig<any, any>, "subscribe"> | undefined;
744
772
  protected getCacheType(gqlType: GraphQLOutputType, fieldName?: string): GraphQLOutputType;
745
773
  get options(): {
746
774
  resolverOptions: ResolvingOptions | undefined;
@@ -755,6 +783,17 @@ declare function getCacheType(gqlType: GraphQLOutputType, options?: {
755
783
  parent?: LoomObjectType;
756
784
  }): GraphQLOutputType;
757
785
 
786
+ interface FieldConvertOptions {
787
+ optionsForResolving?: ResolvingOptions;
788
+ }
789
+ interface CoreSchemaWeaverConfigOptions extends GraphQLSchemaConfig {
790
+ getInputObjectName?: (name: string) => string;
791
+ weaverContext?: WeaverContext;
792
+ }
793
+ interface CoreSchemaWeaverConfig extends WeaverConfig, CoreSchemaWeaverConfigOptions {
794
+ [WEAVER_CONFIG]: "gqloom.core.schema";
795
+ }
796
+
758
797
  interface SchemaWeaverParameters extends Partial<Record<"query" | "mutation" | "subscription", LoomObjectType>>, Pick<GraphQLSchemaConfig, "types"> {
759
798
  }
760
799
  declare class GraphQLSchemaLoom {
@@ -772,22 +811,22 @@ declare class GraphQLSchemaLoom {
772
811
  static config(config: CoreSchemaWeaverConfigOptions): CoreSchemaWeaverConfig;
773
812
  constructor({ query, mutation, subscription, types }?: SchemaWeaverParameters, context?: WeaverContext);
774
813
  use(...middlewares: Middleware[]): this;
775
- add(resolver: SilkResolver): this;
814
+ add(resolver: Resolver): this;
776
815
  addVendor(weaver: SchemaWeaver): this;
777
816
  addType(silk: GraphQLSilk): this;
778
817
  setConfig<TConfig extends WeaverConfig>(config: TConfig): this;
779
818
  weaveGraphQLSchema(): GraphQLSchema;
780
- protected addResolver(resolver: SilkResolver): this;
819
+ protected addResolver(resolver: Resolver): this;
781
820
  protected getOperationObject(type: "query" | "mutation" | "subscription"): LoomObjectType;
782
821
  protected get fieldOptions(): {
783
822
  resolverOptions: ResolvingOptions | undefined;
784
823
  weaverContext: WeaverContext;
785
824
  };
786
- static optionsFrom(...inputs: (SilkResolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): {
825
+ static optionsFrom(...inputs: (Resolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): {
787
826
  context: WeaverContext | undefined;
788
827
  configs: Set<WeaverConfig>;
789
828
  middlewares: Set<Middleware>;
790
- resolvers: Set<SilkResolver>;
829
+ resolvers: Set<Resolver>;
791
830
  silks: Set<GraphQLSilk<any, any>>;
792
831
  weavers: Set<SchemaWeaver>;
793
832
  };
@@ -796,7 +835,7 @@ declare class GraphQLSchemaLoom {
796
835
  * @param inputs Resolvers, Global Middlewares, WeaverConfigs Or SchemaWeaver
797
836
  * @returns GraphQL Schema
798
837
  */
799
- static weave(...inputs: (SilkResolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): GraphQLSchema;
838
+ static weave(...inputs: (Resolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): GraphQLSchema;
800
839
  }
801
840
  /**
802
841
  * Weave a GraphQL Schema from resolvers
@@ -808,7 +847,7 @@ declare const weave: typeof GraphQLSchemaLoom.weave;
808
847
  interface EnsureInputOptions {
809
848
  fieldName?: string;
810
849
  }
811
- declare function inputToArgs(input: InputSchema<GraphQLSilk>, options: EnsureInputOptions | undefined): GraphQLFieldConfigArgumentMap | undefined;
850
+ declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined, options: EnsureInputOptions | undefined): GraphQLFieldConfigArgumentMap | undefined;
812
851
  declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions | undefined): GraphQLInputType;
813
852
  declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions | undefined): GraphQLInputObjectType;
814
853
 
@@ -828,4 +867,4 @@ interface GQLoomExtensionAttribute {
828
867
  directives?: string[];
829
868
  }
830
869
 
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 };
870
+ export { BaseChainFactory, type BatchLoadFn, type CallableContextMemoization, type CallableInputParser, type CallableMiddlewareOptions, type ChainFactoryOptions, ChainResolver, ContextMemoization, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, FieldChainFactory, type FieldConvertOptions, type FieldFactory, FieldFactoryWithResolve, type FieldFactoryWithUtils, type FieldOptions, 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, MutationChainFactory, type MutationFactory, type MutationFactoryWithChain, MutationFactoryWithResolve, type MutationOptions, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, type OmitInUnion, type OnlyMemoizationPayload, type OperationType, QueryChainFactory, type QueryFactory, type QueryFactoryWithChain, QueryFactoryWithResolve, type QueryOptions, type ResolvableSubscription, type ResolverFactory, type ResolverOptions, type ResolverOptionsWithExtensions, type ResolverOptionsWithParent, type ResolverPayload, type ResolvingOptions, symbols as SYMBOLS, type SchemaWeaver, StandardSchemaV1, 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 };