@gqloom/core 0.8.4 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -3
- package/dist/chunk-BQAPYNA7.js +220 -0
- package/dist/context-DsvT0-C6.d.cts +766 -0
- package/dist/context-DsvT0-C6.d.ts +766 -0
- package/dist/context.cjs +453 -0
- package/dist/context.d.cts +137 -0
- package/dist/context.d.ts +137 -0
- package/dist/context.js +234 -0
- package/dist/index.cjs +683 -379
- package/dist/index.d.cts +138 -542
- package/dist/index.d.ts +138 -542
- package/dist/index.js +448 -330
- package/package.json +15 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,398 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
1
|
+
import { F as FieldOptions, Q as QueryOptions, M as MutationOptions, R as ResolverPayload, S as SubscriptionOptions, G as GraphQLFieldOptions, a as StandardSchemaV1, b as GraphQLSilk, c as MayPromise, d as Query, e as QueryChainFactory, f as QueryFactoryWithChain, g as Mutation, h as MutationChainFactory, i as MutationFactoryWithChain, j as Field, k as FieldChainFactory, l as FieldFactoryWithUtils, m as SubscriptionChainFactory, n as Subscription, o as SubscriptionFactoryWithChain, O as Operation, p as FIELD_HIDDEN, q as ResolverOptionsWithExtensions, r as OmitInUnion, V as ValueOf, s as ResolverOptions, t as FieldOrOperation, u as Resolver, I as IS_RESOLVER, v as Middleware, w as InferInputI, W as WEAVER_CONFIG, B as BaseField } from './context-DsvT0-C6.js';
|
|
2
|
+
export { $ as BaseChainFactory, ai as CallableInputParser, D as CallableMiddlewareOptions, _ as ChainFactoryOptions, ae as FieldFactory, a4 as FieldFactoryWithResolve, ag as FieldMeta, a9 as FieldOrOperationType, Z as IChainFactory, aa as InferFieldInput, ab as InferFieldOutput, ah as InferInputO, y as IsAny, a5 as Loom, E as MiddlewareConfig, A as MiddlewareOperation, C as MiddlewareOptions, ad as MutationFactory, a3 as MutationFactoryWithResolve, P as OnlyMemoizationPayload, a8 as OperationType, ac as QueryFactory, a2 as QueryFactoryWithResolve, z as RequireKeys, a0 as ResolvableSubscription, a6 as ResolverOptionsWithParent, K as ResolvingFields, a7 as ResolvingOptions, x as SYMBOLS, af as SubscriptionFactory, a1 as SubscriptionNeedResolve, H as applyMiddlewares, Y as assignContextMap, aj as createInputParser, J as filterMiddlewares, X as getMemoizationMap, L as getResolvingFields, al as getStandardValue, U as isOnlyMemoryPayload, T as onlyMemoization, ak as parseInputValue, N as parseResolvingFields } from './context-DsvT0-C6.js';
|
|
3
|
+
import { GraphQLFieldExtensions, GraphQLScalarType, GraphQLObjectType, GraphQLOutputType, GraphQLNullableType, GraphQLList, GraphQLNonNull, GraphQLObjectTypeConfig, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLFieldMap, GraphQLFieldConfig, GraphQLSchemaConfig, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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. */
|
|
14
|
-
readonly "~standard": StandardSchemaV1.Props<Input, Output>;
|
|
15
|
-
}
|
|
16
|
-
declare namespace StandardSchemaV1 {
|
|
17
|
-
/** The Standard Schema properties interface. */
|
|
18
|
-
export interface Props<Input = unknown, Output = Input> {
|
|
19
|
-
/** The version number of the standard. */
|
|
20
|
-
readonly version: 1;
|
|
21
|
-
/** The vendor name of the schema library. */
|
|
22
|
-
readonly vendor: string;
|
|
23
|
-
/** Validates unknown input values. */
|
|
24
|
-
readonly validate: (value: unknown) => Result<Output> | Promise<Result<Output>>;
|
|
25
|
-
/** Inferred types associated with the schema. */
|
|
26
|
-
readonly types?: Types<Input, Output> | undefined;
|
|
27
|
-
}
|
|
28
|
-
/** The result interface of the validate function. */
|
|
29
|
-
export type Result<Output> = SuccessResult<Output> | FailureResult;
|
|
30
|
-
/** The result interface if validation succeeds. */
|
|
31
|
-
export interface SuccessResult<Output> {
|
|
32
|
-
/** The typed output value. */
|
|
33
|
-
readonly value: Output;
|
|
34
|
-
/** The non-existent issues. */
|
|
35
|
-
readonly issues?: undefined;
|
|
36
|
-
}
|
|
37
|
-
/** The result interface if validation fails. */
|
|
38
|
-
export interface FailureResult {
|
|
39
|
-
/** The issues of failed validation. */
|
|
40
|
-
readonly issues: ReadonlyArray<Issue>;
|
|
41
|
-
}
|
|
42
|
-
/** The issue interface of the failure output. */
|
|
43
|
-
export interface Issue {
|
|
44
|
-
/** The error message of the issue. */
|
|
45
|
-
readonly message: string;
|
|
46
|
-
/** The path of the issue, if any. */
|
|
47
|
-
readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;
|
|
48
|
-
}
|
|
49
|
-
/** The path segment interface of the issue. */
|
|
50
|
-
export interface PathSegment {
|
|
51
|
-
/** The key representing a path segment. */
|
|
52
|
-
readonly key: PropertyKey;
|
|
53
|
-
}
|
|
54
|
-
/** The Standard Schema types interface. */
|
|
55
|
-
export interface Types<Input = unknown, Output = Input> {
|
|
56
|
-
/** The input type of the schema. */
|
|
57
|
-
readonly input: Input;
|
|
58
|
-
/** The output type of the schema. */
|
|
59
|
-
readonly output: Output;
|
|
60
|
-
}
|
|
61
|
-
/** Infers the input type of a Standard Schema. */
|
|
62
|
-
export type InferInput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["input"];
|
|
63
|
-
/** Infers the output type of a Standard Schema. */
|
|
64
|
-
export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<Schema["~standard"]["types"]>["output"];
|
|
65
|
-
export { };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The symbol to get GraphQL type for schema
|
|
70
|
-
*/
|
|
71
|
-
declare const GET_GRAPHQL_TYPE: unique symbol;
|
|
72
|
-
/**
|
|
73
|
-
* The symbol to get and store weaver config
|
|
74
|
-
*/
|
|
75
|
-
declare const WEAVER_CONFIG: unique symbol;
|
|
76
|
-
/**
|
|
77
|
-
* The symbol to get resolver options
|
|
78
|
-
*/
|
|
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;
|
|
84
|
-
/**
|
|
85
|
-
* The symbol to assign a WeakMap to an object
|
|
86
|
-
*/
|
|
87
|
-
declare const CONTEXT_MEMORY_MAP_KEY: unique symbol;
|
|
88
|
-
/**
|
|
89
|
-
* The symbol to set fields to be hidden
|
|
90
|
-
*/
|
|
91
|
-
declare const FIELD_HIDDEN: unique symbol;
|
|
92
|
-
|
|
93
|
-
declare const symbols_CONTEXT_MEMORY_MAP_KEY: typeof CONTEXT_MEMORY_MAP_KEY;
|
|
94
|
-
declare const symbols_FIELD_HIDDEN: typeof FIELD_HIDDEN;
|
|
95
|
-
declare const symbols_GET_GRAPHQL_TYPE: typeof GET_GRAPHQL_TYPE;
|
|
96
|
-
declare const symbols_IS_RESOLVER: typeof IS_RESOLVER;
|
|
97
|
-
declare const symbols_RESOLVER_OPTIONS_KEY: typeof RESOLVER_OPTIONS_KEY;
|
|
98
|
-
declare const symbols_WEAVER_CONFIG: typeof WEAVER_CONFIG;
|
|
99
|
-
declare namespace symbols {
|
|
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 };
|
|
101
|
-
}
|
|
102
|
-
|
|
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> {
|
|
110
|
-
/**
|
|
111
|
-
* input schema
|
|
112
|
-
*/
|
|
113
|
-
schema: TSchema;
|
|
114
|
-
/**
|
|
115
|
-
* Origin value to parse
|
|
116
|
-
*/
|
|
117
|
-
value: InferInputI<TSchema>;
|
|
118
|
-
/**
|
|
119
|
-
* Parse the input and return the standard result
|
|
120
|
-
*/
|
|
121
|
-
(): Promise<StandardSchemaV1.Result<InferInputO<TSchema>>>;
|
|
122
|
-
/**
|
|
123
|
-
* Result of parsing. Set it to `undefined` then the parser will run again.
|
|
124
|
-
*/
|
|
125
|
-
result: StandardSchemaV1.Result<InferInputO<TSchema>> | undefined;
|
|
126
|
-
/**
|
|
127
|
-
* Parse the input and return the result
|
|
128
|
-
*/
|
|
129
|
-
getResult(): Promise<InferInputO<TSchema>>;
|
|
130
|
-
}
|
|
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>>>;
|
|
133
|
-
declare function getStandardValue<T>(result: StandardSchemaV1.Result<T>): T;
|
|
134
|
-
declare function getStandardValue<T>(result?: StandardSchemaV1.Result<T>): T | undefined;
|
|
135
|
-
declare function getStandardValue<T>(result: StandardSchemaV1.Result<T> | null): T | null;
|
|
136
|
-
|
|
137
|
-
interface IChainFactory<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> {
|
|
138
|
-
description(description: GraphQLFieldOptions["description"]): this;
|
|
139
|
-
deprecationReason(deprecationReason: GraphQLFieldOptions["deprecationReason"]): this;
|
|
140
|
-
extensions(extensions: GraphQLFieldOptions["extensions"]): this;
|
|
141
|
-
output<TOutputNew extends GraphQLSilk>(output: TOutputNew): IChainFactory<TOutputNew, TInput>;
|
|
142
|
-
input<TInputNew extends GraphQLSilk | Record<string, GraphQLSilk>>(input: TInputNew): IChainFactory<TOutput, TInputNew>;
|
|
143
|
-
}
|
|
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;
|
|
149
|
-
static methods(): {
|
|
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>;
|
|
153
|
-
};
|
|
154
|
-
constructor(options?: Partial<ChainFactoryOptions> | undefined);
|
|
155
|
-
protected abstract clone(options?: Partial<ChainFactoryOptions>): this;
|
|
156
|
-
description(description: GraphQLFieldOptions["description"]): this;
|
|
157
|
-
deprecationReason(deprecationReason: GraphQLFieldOptions["deprecationReason"]): this;
|
|
158
|
-
extensions(extensions: GraphQLFieldOptions["extensions"]): 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>>): TValue extends StandardSchemaV1.InferOutput<TOutput> ? ResolvableSubscription<TOutput, TInput, TValue> : SubscriptionNeedResolve<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
|
-
interface SubscriptionNeedResolve<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> {
|
|
194
|
-
resolve(resolve: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Subscription<TOutput, TInput, TValue>;
|
|
195
|
-
}
|
|
196
|
-
declare class QueryFactoryWithResolve<TInputO, TOutput extends GraphQLSilk, TInput extends GraphQLSilk<TInputO>> extends BaseChainFactory<Query<TOutput, TInput>> implements Query<TOutput, TInput> {
|
|
197
|
-
protected output: TOutput;
|
|
198
|
-
protected readonly options: QueryOptions<TOutput, TInput>;
|
|
199
|
-
get "~meta"(): Query<TOutput, TInput>["~meta"];
|
|
200
|
-
constructor(output: TOutput, options: QueryOptions<TOutput, TInput>);
|
|
201
|
-
protected clone(options?: Partial<typeof this.options> | undefined): this;
|
|
202
|
-
input<TInputNew extends GraphQLSilk<TInputO>>(input: TInputNew): QueryFactoryWithResolve<TInputO, TOutput, TInputNew>;
|
|
203
|
-
}
|
|
204
|
-
declare class MutationFactoryWithResolve<TInputO, TOutput extends GraphQLSilk, TInput extends GraphQLSilk<TInputO>> extends BaseChainFactory<Query<TOutput, TInput>> implements Mutation<TOutput, TInput> {
|
|
205
|
-
protected output: TOutput;
|
|
206
|
-
protected readonly options: MutationOptions<TOutput, TInput>;
|
|
207
|
-
get "~meta"(): Mutation<TOutput, TInput>["~meta"];
|
|
208
|
-
constructor(output: TOutput, options: MutationOptions<TOutput, TInput>);
|
|
209
|
-
protected clone(options?: Partial<typeof this.options> | undefined): this;
|
|
210
|
-
input<TInputNew extends GraphQLSilk<TInputO>>(input: TInputNew): MutationFactoryWithResolve<TInputO, TOutput, TInputNew>;
|
|
211
|
-
}
|
|
212
|
-
declare class FieldFactoryWithResolve<TParent extends GraphQLSilk, TOutput extends GraphQLSilk> extends BaseChainFactory<Field<TParent, TOutput, undefined>> {
|
|
213
|
-
protected output: TOutput;
|
|
214
|
-
protected readonly options: FieldOptions<TParent, TOutput, undefined>;
|
|
215
|
-
get "~meta"(): Field<TParent, TOutput, undefined>["~meta"];
|
|
216
|
-
constructor(output: TOutput, options: FieldOptions<TParent, TOutput, undefined>);
|
|
217
|
-
protected clone(options?: Partial<typeof this.options> | undefined): this;
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
interface FieldMeta extends GraphQLFieldOptions {
|
|
221
|
-
operation: "field" | "query" | "mutation" | "subscription";
|
|
222
|
-
output: GraphQLSilk;
|
|
223
|
-
input: GraphQLSilk | Record<string, GraphQLSilk> | undefined;
|
|
224
|
-
resolve: (...args: any) => MayPromise<any>;
|
|
225
|
-
}
|
|
226
|
-
interface BaseField {
|
|
227
|
-
readonly "~meta": FieldMeta;
|
|
228
|
-
}
|
|
229
|
-
interface Field<TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseField {
|
|
230
|
-
"~meta": {
|
|
231
|
-
operation: "field";
|
|
232
|
-
output: TOutput;
|
|
233
|
-
input: TInput;
|
|
234
|
-
types?: {
|
|
235
|
-
parent: ReSilk<TParent>;
|
|
236
|
-
};
|
|
237
|
-
resolve: (parent: StandardSchemaV1.InferOutput<NonNullable<TParent>>, input: InferInputI<TInput>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
238
|
-
} & GraphQLFieldOptions;
|
|
239
|
-
}
|
|
240
|
-
interface Query<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseField {
|
|
241
|
-
"~meta": {
|
|
242
|
-
operation: "query";
|
|
243
|
-
parent?: undefined;
|
|
244
|
-
output: TOutput;
|
|
245
|
-
input: TInput;
|
|
246
|
-
resolve: (input: InferInputI<TInput>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
247
|
-
} & GraphQLFieldOptions;
|
|
248
|
-
}
|
|
249
|
-
interface Mutation<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends BaseField {
|
|
250
|
-
"~meta": {
|
|
251
|
-
operation: "mutation";
|
|
252
|
-
parent?: undefined;
|
|
253
|
-
output: TOutput;
|
|
254
|
-
input: TInput;
|
|
255
|
-
resolve: (input: InferInputI<TInput>, options?: ResolvingOptions) => Promise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
256
|
-
} & GraphQLFieldOptions;
|
|
257
|
-
}
|
|
258
|
-
interface Subscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends BaseField {
|
|
259
|
-
"~meta": {
|
|
260
|
-
operation: "subscription";
|
|
261
|
-
parent?: undefined;
|
|
262
|
-
output: TOutput;
|
|
263
|
-
input: TInput;
|
|
264
|
-
types?: {
|
|
265
|
-
value: TValue;
|
|
266
|
-
} & GraphQLFieldOptions;
|
|
267
|
-
resolve: (value: TValue, input: InferInputI<TInput>, options?: ResolvingOptions) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
268
|
-
subscribe: (input: InferInputI<TInput>, options?: ResolvingOptions) => MayPromise<AsyncIterator<TValue>>;
|
|
269
|
-
} & GraphQLFieldOptions;
|
|
270
|
-
}
|
|
271
|
-
interface Resolver {
|
|
272
|
-
readonly "~meta": {
|
|
273
|
-
[IS_RESOLVER]: true;
|
|
274
|
-
fields: Record<string, BaseField | typeof FIELD_HIDDEN>;
|
|
275
|
-
options?: ResolverOptionsWithExtensions<any>;
|
|
276
|
-
parent?: GraphQLSilk;
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
type Operation = Query<GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> | Mutation<GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> | Subscription<GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined, any>;
|
|
280
|
-
type FieldOrOperation = Field<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> | Operation;
|
|
281
|
-
type ReSilk<T extends GraphQLSilk> = GraphQLSilk<NonNullable<T["~standard"]["types"]>["output"], NonNullable<T["~standard"]["types"]>["input"]>;
|
|
282
|
-
|
|
283
|
-
type typesLoom_BaseField = BaseField;
|
|
284
|
-
type typesLoom_Field<TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> = Field<TParent, TOutput, TInput>;
|
|
285
|
-
type typesLoom_FieldMeta = FieldMeta;
|
|
286
|
-
type typesLoom_FieldOrOperation = FieldOrOperation;
|
|
287
|
-
type typesLoom_Mutation<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> = Mutation<TOutput, TInput>;
|
|
288
|
-
type typesLoom_Operation = Operation;
|
|
289
|
-
type typesLoom_Query<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> = Query<TOutput, TInput>;
|
|
290
|
-
type typesLoom_Resolver = Resolver;
|
|
291
|
-
type typesLoom_Subscription<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> = Subscription<TOutput, TInput, TValue>;
|
|
292
|
-
declare namespace typesLoom {
|
|
293
|
-
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 };
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
interface GraphQLSilk<TOutput = any, TInput = any> extends StandardSchemaV1<TInput, TOutput> {
|
|
297
|
-
/**
|
|
298
|
-
* GraphQL type for schema
|
|
299
|
-
*/
|
|
300
|
-
[GET_GRAPHQL_TYPE]?: () => GraphQLOutputType;
|
|
301
|
-
}
|
|
302
|
-
interface ResolverOptions<TField extends FieldOrOperation = FieldOrOperation> {
|
|
303
|
-
middlewares?: Middleware<TField>[];
|
|
304
|
-
}
|
|
305
|
-
interface ResolverOptionsWithExtensions<TField extends FieldOrOperation = FieldOrOperation> extends ResolverOptions<TField>, Pick<GraphQLObjectTypeConfig<any, any>, "extensions"> {
|
|
306
|
-
}
|
|
307
|
-
interface ResolverOptionsWithParent<TField extends FieldOrOperation = FieldOrOperation> extends ResolverOptionsWithExtensions<TField> {
|
|
308
|
-
parent?: TField extends Field<infer TParent, any, any> ? TParent : undefined;
|
|
309
|
-
}
|
|
310
|
-
interface ResolvingOptions extends Pick<ResolverOptions, "middlewares"> {
|
|
311
|
-
}
|
|
312
|
-
type OperationType = "query" | "mutation" | "subscription";
|
|
313
|
-
type FieldOrOperationType = "field" | OperationType;
|
|
314
|
-
interface GraphQLFieldOptions extends Pick<GraphQLFieldConfig<any, any>, "description" | "deprecationReason" | "extensions"> {
|
|
315
|
-
}
|
|
316
|
-
type InferFieldInput<TField extends BaseField> = TField["~meta"]["input"];
|
|
317
|
-
type InferFieldOutput<TField extends BaseField> = TField["~meta"]["output"];
|
|
318
|
-
/**
|
|
319
|
-
* Options for creating a GraphQL Query.
|
|
320
|
-
*/
|
|
321
|
-
interface QueryOptions<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends ResolverOptions<Query<TOutput, TInput>>, GraphQLFieldOptions {
|
|
322
|
-
input?: TInput;
|
|
323
|
-
resolve: (input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
324
|
-
}
|
|
325
|
-
/**
|
|
326
|
-
* Options for creating a GraphQL Mutation.
|
|
327
|
-
*/
|
|
328
|
-
interface MutationOptions<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends ResolverOptions<Mutation<TOutput, TInput>>, GraphQLFieldOptions {
|
|
329
|
-
input?: TInput;
|
|
330
|
-
resolve: (input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Function to create a GraphQL query.
|
|
334
|
-
*/
|
|
335
|
-
interface QueryFactory {
|
|
336
|
-
<TOutput extends GraphQLSilk>(output: TOutput, resolve: () => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Query<TOutput, undefined>;
|
|
337
|
-
<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined>(output: TOutput, options: QueryOptions<TOutput, TInput>): Query<TOutput, TInput>;
|
|
338
|
-
<TOutput extends GraphQLSilk>(output: TOutput): QueryChainFactory<TOutput, undefined>;
|
|
339
|
-
}
|
|
340
|
-
interface QueryFactoryWithChain extends QueryFactory, QueryChainFactory<never, undefined> {
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Function to create a GraphQL mutation.
|
|
344
|
-
*/
|
|
345
|
-
interface MutationFactory {
|
|
346
|
-
<TOutput extends GraphQLSilk>(output: TOutput, resolve: () => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Mutation<TOutput, undefined>;
|
|
347
|
-
<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined>(output: TOutput, options: MutationOptions<TOutput, TInput>): Mutation<TOutput, TInput>;
|
|
348
|
-
<TOutput extends GraphQLSilk>(output: TOutput): MutationChainFactory<TOutput, undefined>;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* Function to create a GraphQL mutation.
|
|
352
|
-
*/
|
|
353
|
-
interface MutationFactoryWithChain extends MutationFactory, MutationChainFactory<never, undefined> {
|
|
354
|
-
}
|
|
355
|
-
/**
|
|
356
|
-
* Options for External Filed of existing GraphQL Object.
|
|
357
|
-
*/
|
|
358
|
-
interface FieldOptions<TParent extends GraphQLSilk, TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined> extends ResolverOptions<Field<TParent, TOutput, TInput>>, GraphQLFieldOptions {
|
|
359
|
-
input?: TInput;
|
|
360
|
-
resolve: (parent: StandardSchemaV1.InferOutput<TParent>, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* Function to create a GraphQL Field.
|
|
364
|
-
*/
|
|
365
|
-
interface FieldFactory {
|
|
366
|
-
<TParent extends GraphQLSilk, TOutput extends GraphQLSilk>(output: TOutput, resolve: (parent: StandardSchemaV1.InferOutput<TParent>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>): Field<TParent, TOutput, undefined>;
|
|
367
|
-
<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>;
|
|
368
|
-
<TOutput extends GraphQLSilk>(output: TOutput): FieldChainFactory<TOutput, undefined>;
|
|
369
|
-
}
|
|
370
|
-
interface FieldFactoryWithUtils extends FieldFactory, FieldChainFactory<never, undefined> {
|
|
371
|
-
/** Set fields to be hidden in GraphQL Schema */
|
|
372
|
-
hidden: typeof FIELD_HIDDEN;
|
|
373
|
-
}
|
|
374
|
-
/**
|
|
375
|
-
* Options for creating a GraphQL Subscription.
|
|
376
|
-
*/
|
|
377
|
-
interface SubscriptionOptions<TOutput extends GraphQLSilk, TInput extends GraphQLSilk | Record<string, GraphQLSilk> | undefined = undefined, TValue = StandardSchemaV1.InferOutput<TOutput>> extends ResolverOptions<Subscription<TOutput, TInput, TValue>>, GraphQLFieldOptions {
|
|
378
|
-
input?: TInput;
|
|
379
|
-
subscribe: (input: InferInputO<TInput>) => MayPromise<AsyncIterator<TValue>>;
|
|
380
|
-
resolve?: (value: TValue, input: InferInputO<TInput>) => MayPromise<StandardSchemaV1.InferOutput<TOutput>>;
|
|
381
|
-
}
|
|
382
|
-
/**
|
|
383
|
-
* Function to create a GraphQL subscription.
|
|
384
|
-
*/
|
|
385
|
-
interface SubscriptionFactory {
|
|
386
|
-
<TOutput extends GraphQLSilk, TValue = StandardSchemaV1.InferOutput<TOutput>>(output: TOutput, subscribe: () => MayPromise<AsyncIterator<StandardSchemaV1.InferOutput<TOutput>>>): Subscription<TOutput, undefined, TValue>;
|
|
387
|
-
<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>;
|
|
388
|
-
<TOutput extends GraphQLSilk>(output: TOutput): SubscriptionChainFactory<TOutput, undefined>;
|
|
389
|
-
}
|
|
390
|
-
interface SubscriptionFactoryWithChain extends SubscriptionFactory, SubscriptionChainFactory<never, undefined> {
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
declare function getOperationOptions(resolveOrOptions: ((...args: any) => any) | FieldOptions<any, any, any> | QueryOptions<any, any> | MutationOptions<any, any>): any;
|
|
394
|
-
declare function getSubscriptionOptions(subscribeOrOptions: (() => any) | SubscriptionOptions<any, any, any>): SubscriptionOptions<any, any, any>;
|
|
395
|
-
declare function getFieldOptions({ description, deprecationReason, extensions, }: GraphQLFieldOptions): GraphQLFieldOptions;
|
|
5
|
+
declare function getOperationOptions(resolveOrOptions: ((...args: any) => any) | FieldOptions<any, any, any, any> | QueryOptions<any, any> | MutationOptions<any, any>): any;
|
|
6
|
+
declare function getSubscriptionOptions(subscribeOrOptions: ((payload: ResolverPayload | undefined) => any) | SubscriptionOptions<any, any, any>): SubscriptionOptions<any, any, any>;
|
|
7
|
+
declare function getFieldOptions({ description, deprecationReason, extensions }: GraphQLFieldOptions, extraExtensions?: GraphQLFieldExtensions<any, any, any>): GraphQLFieldOptions;
|
|
396
8
|
|
|
397
9
|
/**
|
|
398
10
|
* Create a Silk from Scalar.
|
|
@@ -448,17 +60,65 @@ type InferScalarExternalByVariants<T extends GraphQLVariants<GraphQLScalarType>>
|
|
|
448
60
|
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;
|
|
449
61
|
type EnsureArray<T> = T extends Array<infer U> ? U[] : T[];
|
|
450
62
|
|
|
451
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Creates a GraphQL query resolver
|
|
65
|
+
* @param output - The output type definition for the query
|
|
66
|
+
* @param resolveOrOptions - Either a resolve function or options object
|
|
67
|
+
* @returns A GraphQL query resolver
|
|
68
|
+
*/
|
|
69
|
+
declare const createQuery: (output: GraphQLSilk<any, any>, resolveOrOptions?: ((...args: any) => MayPromise<unknown>) | QueryOptions<any, any>) => Query<any, any> | QueryChainFactory<never, void>;
|
|
70
|
+
/**
|
|
71
|
+
* Factory function for creating GraphQL queries with chainable configuration
|
|
72
|
+
*/
|
|
452
73
|
declare const query: QueryFactoryWithChain;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a GraphQL mutation resolver
|
|
76
|
+
* @param output - The output type definition for the mutation
|
|
77
|
+
* @param resolveOrOptions - Either a resolve function or options object
|
|
78
|
+
* @returns A GraphQL mutation resolver
|
|
79
|
+
*/
|
|
453
80
|
declare const createMutation: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => MayPromise<unknown>) | MutationOptions<any, any>) => Mutation<any, any> | MutationChainFactory<never, undefined>;
|
|
81
|
+
/**
|
|
82
|
+
* Factory function for creating GraphQL mutations with chainable configuration
|
|
83
|
+
*/
|
|
454
84
|
declare const mutation: MutationFactoryWithChain;
|
|
455
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Creates a GraphQL field resolver
|
|
87
|
+
* @param output - The output type definition for the field
|
|
88
|
+
* @param resolveOrOptions - Either a resolve function or options object
|
|
89
|
+
* @returns A GraphQL field resolver
|
|
90
|
+
*/
|
|
91
|
+
declare const createField: (output: GraphQLSilk<any, any>, resolveOrOptions?: (() => unknown) | FieldOptions<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | void, string[] | undefined>) => Field<any, any, any, any> | FieldChainFactory<never, undefined, undefined>;
|
|
92
|
+
/**
|
|
93
|
+
* Factory function for creating GraphQL fields with chainable configuration
|
|
94
|
+
*/
|
|
456
95
|
declare const field: FieldFactoryWithUtils;
|
|
96
|
+
/**
|
|
97
|
+
* Default subscription resolver that returns the source value
|
|
98
|
+
* @param source - The source value to resolve
|
|
99
|
+
*/
|
|
457
100
|
declare const defaultSubscriptionResolve: (source: any) => any;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a GraphQL subscription resolver
|
|
103
|
+
* @param output - The output type definition for the subscription
|
|
104
|
+
* @returns A subscription chain factory
|
|
105
|
+
*/
|
|
458
106
|
declare function createSubscription(output: GraphQLSilk<any, any>): SubscriptionChainFactory;
|
|
107
|
+
/**
|
|
108
|
+
* Creates a GraphQL subscription resolver with subscribe function
|
|
109
|
+
* @param output - The output type definition for the subscription
|
|
110
|
+
* @param subscribeOrOptions - Either a subscribe function or options object
|
|
111
|
+
* @returns A GraphQL subscription resolver
|
|
112
|
+
*/
|
|
459
113
|
declare function createSubscription(output: GraphQLSilk<any, any>, subscribeOrOptions: (() => MayPromise<AsyncIterator<unknown>>) | SubscriptionOptions<any, any, any>): Subscription<any, any, any>;
|
|
114
|
+
/**
|
|
115
|
+
* Factory function for creating GraphQL subscriptions with chainable configuration
|
|
116
|
+
*/
|
|
460
117
|
declare const subscription: SubscriptionFactoryWithChain;
|
|
461
118
|
declare const resolver: ResolverFactory;
|
|
119
|
+
/**
|
|
120
|
+
* Collection of factory functions for creating GraphQL operations
|
|
121
|
+
*/
|
|
462
122
|
declare const loom: {
|
|
463
123
|
query: QueryFactoryWithChain;
|
|
464
124
|
resolver: ResolverFactory;
|
|
@@ -466,21 +126,67 @@ declare const loom: {
|
|
|
466
126
|
subscription: SubscriptionFactoryWithChain;
|
|
467
127
|
mutation: MutationFactoryWithChain;
|
|
468
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* Properties for creating an executor
|
|
131
|
+
*/
|
|
132
|
+
interface ToExecutorProps {
|
|
133
|
+
/** WeakMap for memoization */
|
|
134
|
+
memoization?: WeakMap<WeakKey, any>;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Factory interface for creating GraphQL resolvers
|
|
138
|
+
*/
|
|
469
139
|
interface ResolverFactory {
|
|
470
|
-
|
|
140
|
+
/**
|
|
141
|
+
* Creates a resolver for an object type
|
|
142
|
+
* @template TParent - The parent type
|
|
143
|
+
* @template TFields - The fields of the object type
|
|
144
|
+
* @param parent - The parent type definition
|
|
145
|
+
* @param fields - The fields to resolve
|
|
146
|
+
* @param options - Optional resolver options
|
|
147
|
+
*/
|
|
148
|
+
of<TParent extends GraphQLSilk, TFields extends Record<string, Field<TParent, any, any, any> | Operation | typeof FIELD_HIDDEN>>(parent: TParent, fields: TFields, options?: ResolverOptionsWithExtensions<OmitInUnion<ValueOf<TFields>, typeof FIELD_HIDDEN>>): ObjectChainResolver<TParent, TFields>;
|
|
149
|
+
/**
|
|
150
|
+
* Creates a resolver for operations
|
|
151
|
+
* @template TFields - The operations to resolve
|
|
152
|
+
* @param operations - The operations to resolve
|
|
153
|
+
* @param options - Optional resolver options
|
|
154
|
+
*/
|
|
471
155
|
<TFields extends Record<string, Operation>>(operations: TFields, options?: ResolverOptions<ValueOf<TFields>>): ChainResolver<TFields>;
|
|
472
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Base class for chain resolvers
|
|
159
|
+
* @template TFields - The fields or operations to resolve
|
|
160
|
+
*/
|
|
473
161
|
declare class ChainResolver<TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> implements Resolver {
|
|
474
162
|
protected meta: {
|
|
475
163
|
[IS_RESOLVER]: true;
|
|
476
164
|
fields: TFields;
|
|
477
165
|
options?: ResolverOptionsWithExtensions;
|
|
478
166
|
};
|
|
167
|
+
/**
|
|
168
|
+
* Creates a new chain resolver
|
|
169
|
+
* @param fields - The fields or operations to resolve
|
|
170
|
+
* @param options - Optional resolver options
|
|
171
|
+
*/
|
|
479
172
|
constructor(fields: TFields, options?: ResolverOptionsWithExtensions<any>);
|
|
173
|
+
/**
|
|
174
|
+
* Gets the metadata for the resolver
|
|
175
|
+
*/
|
|
480
176
|
get "~meta"(): typeof this.meta;
|
|
177
|
+
/**
|
|
178
|
+
* Adds middleware functions to the resolver
|
|
179
|
+
* @param middlewares - The middleware functions to add
|
|
180
|
+
*/
|
|
481
181
|
use(...middlewares: Middleware<OmitInUnion<ValueOf<TFields>, typeof FIELD_HIDDEN>>[]): this;
|
|
482
|
-
toExecutor(): Executor<TFields>;
|
|
182
|
+
toExecutor(...middlewares: Middleware[]): Executor<TFields>;
|
|
183
|
+
protected toExecutorOperation(field: FieldOrOperation | typeof FIELD_HIDDEN, executorMiddlewares: Middleware[]): ((...args: any) => any) | undefined;
|
|
483
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* Class for resolving object types
|
|
187
|
+
* @template TParent - The parent type
|
|
188
|
+
* @template TFields - The fields to resolve
|
|
189
|
+
*/
|
|
484
190
|
declare class ObjectChainResolver<TParent extends GraphQLSilk, TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> extends ChainResolver<TFields> {
|
|
485
191
|
protected meta: {
|
|
486
192
|
[IS_RESOLVER]: true;
|
|
@@ -488,138 +194,30 @@ declare class ObjectChainResolver<TParent extends GraphQLSilk, TFields extends R
|
|
|
488
194
|
parent: TParent;
|
|
489
195
|
options?: ResolverOptionsWithExtensions;
|
|
490
196
|
};
|
|
491
|
-
constructor(parent: TParent, fields: TFields, options?: ResolverOptionsWithExtensions<any>);
|
|
492
|
-
get "~meta"(): typeof this.meta;
|
|
493
|
-
extensions(extensions: Pick<GraphQLObjectTypeConfig<any, any>, "extensions">["extensions"]): this;
|
|
494
|
-
}
|
|
495
|
-
type Executor<TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> = {
|
|
496
|
-
[K in keyof TFields]: TFields[K] extends FieldOrOperation ? TFields[K]["~meta"]["resolve"] : never;
|
|
497
|
-
};
|
|
498
|
-
|
|
499
|
-
interface MiddlewareOptions<TField extends BaseField = BaseField> {
|
|
500
|
-
/** The Output Silk of the field */
|
|
501
|
-
outputSilk: StandardSchemaV1.InferOutput<InferFieldOutput<TField>>;
|
|
502
|
-
/** The previous object, which for a field on the root Query type is often not used. */
|
|
503
|
-
parent: TField extends Field<GraphQLSilk, GraphQLSilk, GraphQLSilk | Record<string, GraphQLSilk> | undefined> ? StandardSchemaV1.InferOutput<NonNullable<TField["~meta"]["types"]>["parent"]> : undefined;
|
|
504
|
-
/** A function to parse the input of the field */
|
|
505
|
-
parseInput: CallableInputParser<TField["~meta"]["input"]>;
|
|
506
|
-
/** The operation of the field: `query`, `mutation`, `subscription` or `field` */
|
|
507
|
-
operation: BaseField["~meta"]["operation"];
|
|
508
|
-
}
|
|
509
|
-
interface CallableMiddlewareOptions<TField extends BaseField = BaseField> extends MiddlewareOptions<TField> {
|
|
510
|
-
/** The function to call next in the middleware chain. */
|
|
511
|
-
next: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
512
|
-
/** The function to call next in the middleware chain. */
|
|
513
|
-
(): MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
514
|
-
}
|
|
515
|
-
type Middleware<TField extends BaseField = any> = (options: CallableMiddlewareOptions<TField>) => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
516
|
-
declare function applyMiddlewares<TField extends BaseField = BaseField>(middlewares: Middleware[], resolveFunction: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>, options: MiddlewareOptions<TField>): Promise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
517
|
-
declare function compose<T>(...lists: (T[] | undefined)[]): T[];
|
|
518
|
-
|
|
519
|
-
/**
|
|
520
|
-
* Detailed payload of the current resolver
|
|
521
|
-
*/
|
|
522
|
-
interface ResolverPayload<TContext extends object = object, TField extends BaseField = BaseField> {
|
|
523
|
-
/**
|
|
524
|
-
* The previous object, which for a field on the root Query type is often not used.
|
|
525
|
-
*/
|
|
526
|
-
readonly root: any;
|
|
527
|
-
/**
|
|
528
|
-
* The arguments provided to the field in the GraphQL query.
|
|
529
|
-
*/
|
|
530
|
-
readonly args: Record<string, any>;
|
|
531
|
-
/**
|
|
532
|
-
* The resolved value of the field, or an error.
|
|
533
|
-
*/
|
|
534
|
-
readonly context: TContext;
|
|
535
|
-
/**
|
|
536
|
-
* A custom object each resolver can read from/write to.
|
|
537
|
-
*/
|
|
538
|
-
readonly info: GraphQLResolveInfo;
|
|
539
|
-
/**
|
|
540
|
-
* The field that is being resolved.
|
|
541
|
-
*/
|
|
542
|
-
readonly field: TField;
|
|
543
|
-
}
|
|
544
|
-
/**
|
|
545
|
-
* Empty Resolver Arguments that only store the memoization
|
|
546
|
-
*/
|
|
547
|
-
interface OnlyMemoizationPayload {
|
|
548
|
-
memoization: WeakMap<WeakKey, any>;
|
|
549
|
-
isMemoization: true;
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Create an empty memoization payload for the resolver
|
|
553
|
-
* @returns the empty memoization payload
|
|
554
|
-
*/
|
|
555
|
-
declare function onlyMemoization(): OnlyMemoizationPayload;
|
|
556
|
-
declare function isOnlyMemoryPayload(payload: ResolverPayload | OnlyMemoizationPayload): payload is OnlyMemoizationPayload;
|
|
557
|
-
/**
|
|
558
|
-
* the AsyncLocalStorage instance to store the resolver payload
|
|
559
|
-
*/
|
|
560
|
-
declare const resolverPayloadStorage: AsyncLocalStorage<ResolverPayload<object, BaseField> | OnlyMemoizationPayload>;
|
|
561
|
-
/**
|
|
562
|
-
* use detailed payload of the current resolver
|
|
563
|
-
* @returns the resolver payload
|
|
564
|
-
*/
|
|
565
|
-
declare function useResolverPayload(): ResolverPayload | undefined;
|
|
566
|
-
/**
|
|
567
|
-
* use context of the current resolver
|
|
568
|
-
* @returns the context of the current resolver
|
|
569
|
-
*/
|
|
570
|
-
declare function useContext<TContextType = object>(): TContextType;
|
|
571
|
-
/**
|
|
572
|
-
* use the MemoizationMap of the current context
|
|
573
|
-
*/
|
|
574
|
-
declare function useMemoizationMap(): WeakMap<WeakKey, any> | undefined;
|
|
575
|
-
interface ContextMemoryContainer {
|
|
576
|
-
[CONTEXT_MEMORY_MAP_KEY]?: WeakMap<WeakKey, any>;
|
|
577
|
-
}
|
|
578
|
-
interface ContextMemoryOptions {
|
|
579
|
-
getMemoizationMap: () => WeakMap<WeakKey, any> | undefined;
|
|
580
|
-
key: WeakKey;
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Create a memoization in context to store the result of a getter function
|
|
584
|
-
*/
|
|
585
|
-
declare class ContextMemoization<T> implements ContextMemoryOptions {
|
|
586
|
-
readonly getter: () => T;
|
|
587
|
-
constructor(getter: () => T, options?: Partial<ContextMemoryOptions>);
|
|
588
|
-
getMemoizationMap: () => WeakMap<WeakKey, any> | undefined;
|
|
589
|
-
readonly key: WeakKey;
|
|
590
197
|
/**
|
|
591
|
-
*
|
|
592
|
-
* @
|
|
198
|
+
* Creates a new object chain resolver
|
|
199
|
+
* @param parent - The parent type definition
|
|
200
|
+
* @param fields - The fields to resolve
|
|
201
|
+
* @param options - Optional resolver options
|
|
593
202
|
*/
|
|
594
|
-
|
|
595
|
-
/**
|
|
596
|
-
* Clear the memoization
|
|
597
|
-
* @returns true if the memoization is cleared, undefined if the context is not found
|
|
598
|
-
*/
|
|
599
|
-
clear(): boolean | undefined;
|
|
203
|
+
constructor(parent: TParent, fields: TFields, options?: ResolverOptionsWithExtensions<any>);
|
|
600
204
|
/**
|
|
601
|
-
*
|
|
602
|
-
* @returns true if the memoization exists, undefined if the context is not found
|
|
205
|
+
* Gets the metadata for the resolver
|
|
603
206
|
*/
|
|
604
|
-
|
|
207
|
+
get "~meta"(): typeof this.meta;
|
|
605
208
|
/**
|
|
606
|
-
*
|
|
607
|
-
* @param
|
|
608
|
-
* @returns the memoization map or undefined if the context is not found
|
|
209
|
+
* Sets custom extensions for the resolver
|
|
210
|
+
* @param extensions - The extensions to add
|
|
609
211
|
*/
|
|
610
|
-
|
|
611
|
-
static assignMemoizationMap(target: ContextMemoryContainer): WeakMap<WeakKey, any>;
|
|
612
|
-
}
|
|
613
|
-
/**
|
|
614
|
-
* Async Memoization with a callable function
|
|
615
|
-
*/
|
|
616
|
-
interface CallableContextMemoization<T> extends Pick<ContextMemoization<T>, "get" | "set" | "clear" | "exists" | "getter"> {
|
|
617
|
-
(): T;
|
|
212
|
+
extensions(extensions: Pick<GraphQLObjectTypeConfig<any, any>, "extensions">["extensions"]): this;
|
|
618
213
|
}
|
|
619
214
|
/**
|
|
620
|
-
*
|
|
215
|
+
* Type for the executor of a resolver
|
|
216
|
+
* @template TFields - The fields or operations to resolve
|
|
621
217
|
*/
|
|
622
|
-
|
|
218
|
+
type Executor<TFields extends Record<string, FieldOrOperation | typeof FIELD_HIDDEN>> = {
|
|
219
|
+
[K in keyof TFields]: TFields[K] extends Field<infer TParent, infer TOutput, infer TInput, string[] | undefined> ? (parent: StandardSchemaV1.InferOutput<TParent>, args: InferInputI<TInput>, payload: ResolverPayload | void) => Promise<StandardSchemaV1.InferOutput<TOutput>> : TFields[K] extends Query<infer TOutput, infer TInput> ? (args: InferInputI<TInput>, payload: ResolverPayload | void) => Promise<StandardSchemaV1.InferOutput<TOutput>> : TFields[K] extends Mutation<infer TOutput, infer TInput> ? (args: InferInputI<TInput>, payload: ResolverPayload | void) => Promise<StandardSchemaV1.InferOutput<TOutput>> : never;
|
|
220
|
+
};
|
|
623
221
|
|
|
624
222
|
/**
|
|
625
223
|
* Creates an object map with the same keys as `map` and values generated by
|
|
@@ -754,10 +352,14 @@ declare class LoomObjectType extends GraphQLObjectType {
|
|
|
754
352
|
protected hiddenFields: Set<string>;
|
|
755
353
|
static AUTO_ALIASING: "__gqloom_auto_aliasing";
|
|
756
354
|
protected weaverContext: WeaverContext;
|
|
757
|
-
protected
|
|
355
|
+
protected globalOptions?: ResolverOptions;
|
|
356
|
+
/**
|
|
357
|
+
* field name -> resolver
|
|
358
|
+
*/
|
|
359
|
+
protected resolvers: Map<string, Resolver>;
|
|
758
360
|
constructor(objectOrGetter: string | GraphQLObjectType | GraphQLObjectTypeConfig<any, any> | (() => GraphQLObjectType | GraphQLObjectTypeConfig<any, any>), options?: {
|
|
759
361
|
weaverContext?: WeaverContext;
|
|
760
|
-
|
|
362
|
+
globalOptions?: ResolverOptions;
|
|
761
363
|
});
|
|
762
364
|
protected hasExplicitName?: boolean;
|
|
763
365
|
protected _aliases: string[];
|
|
@@ -765,31 +367,28 @@ declare class LoomObjectType extends GraphQLObjectType {
|
|
|
765
367
|
addAlias(name: string): void;
|
|
766
368
|
protected renameByAliases(): void;
|
|
767
369
|
hideField(name: string): void;
|
|
768
|
-
addField(name: string, resolver:
|
|
370
|
+
addField(name: string, field: BaseField, resolver: Resolver | undefined): void;
|
|
769
371
|
mergeExtensions(extensions: GraphQLObjectTypeConfig<any, any>["extensions"]): void;
|
|
770
372
|
private extraFieldMap?;
|
|
771
373
|
getFields(): GraphQLFieldMap<any, any>;
|
|
772
374
|
protected mapToFieldConfig(map: Map<string, BaseField>): Record<string, GraphQLFieldConfig<any, any>>;
|
|
773
|
-
toFieldConfig(field: BaseField, fieldName
|
|
774
|
-
protected provideForResolve(field: BaseField):
|
|
775
|
-
protected provideForSubscribe(field: BaseField | Subscription<any, any, any
|
|
375
|
+
toFieldConfig(field: BaseField, fieldName: string): GraphQLFieldConfig<any, any>;
|
|
376
|
+
protected provideForResolve(field: BaseField, fieldName: string): GraphQLFieldConfig<any, any>["resolve"];
|
|
377
|
+
protected provideForSubscribe(field: BaseField | Subscription<any, any, any>, fieldName: string): GraphQLFieldConfig<any, any>["subscribe"] | undefined;
|
|
776
378
|
protected getCacheType(gqlType: GraphQLOutputType, fieldName?: string): GraphQLOutputType;
|
|
777
379
|
get options(): {
|
|
778
|
-
resolverOptions:
|
|
380
|
+
resolverOptions: ResolverOptions<FieldOrOperation> | undefined;
|
|
779
381
|
weaverContext: WeaverContext;
|
|
780
382
|
};
|
|
781
383
|
}
|
|
782
384
|
declare const OPERATION_OBJECT_NAMES: Set<string>;
|
|
783
385
|
declare function getCacheType(gqlType: GraphQLOutputType, options?: {
|
|
784
386
|
weaverContext?: WeaverContext;
|
|
785
|
-
resolverOptions?:
|
|
387
|
+
resolverOptions?: ResolverOptions;
|
|
786
388
|
fieldName?: string;
|
|
787
389
|
parent?: LoomObjectType;
|
|
788
390
|
}): GraphQLOutputType;
|
|
789
391
|
|
|
790
|
-
interface FieldConvertOptions {
|
|
791
|
-
optionsForResolving?: ResolvingOptions;
|
|
792
|
-
}
|
|
793
392
|
interface CoreSchemaWeaverConfigOptions extends GraphQLSchemaConfig {
|
|
794
393
|
getInputObjectName?: (name: string) => string;
|
|
795
394
|
weaverContext?: WeaverContext;
|
|
@@ -806,7 +405,7 @@ declare class GraphQLSchemaLoom {
|
|
|
806
405
|
subscription?: LoomObjectType;
|
|
807
406
|
types: Set<GraphQLNamedType>;
|
|
808
407
|
context: WeaverContext;
|
|
809
|
-
resolverOptions?:
|
|
408
|
+
resolverOptions?: ResolverOptions;
|
|
810
409
|
/**
|
|
811
410
|
* Create a Schema Weaver config object
|
|
812
411
|
* @param config Schema Weaver config options
|
|
@@ -815,21 +414,18 @@ declare class GraphQLSchemaLoom {
|
|
|
815
414
|
static config(config: CoreSchemaWeaverConfigOptions): CoreSchemaWeaverConfig;
|
|
816
415
|
constructor({ query, mutation, subscription, types }?: SchemaWeaverParameters, context?: WeaverContext);
|
|
817
416
|
use(...middlewares: Middleware[]): this;
|
|
818
|
-
add(resolver: Resolver): this;
|
|
417
|
+
add(resolver: Resolver, modifyParent?: (parent: LoomObjectType) => LoomObjectType): this;
|
|
819
418
|
addVendor(weaver: SchemaWeaver): this;
|
|
820
419
|
addType(silk: GraphQLSilk): this;
|
|
821
420
|
setConfig<TConfig extends WeaverConfig>(config: TConfig): this;
|
|
822
421
|
weaveGraphQLSchema(): GraphQLSchema;
|
|
823
|
-
protected addResolver(resolver: Resolver): this;
|
|
422
|
+
protected addResolver(resolver: Resolver, modifyParent?: (parent: LoomObjectType) => LoomObjectType): this;
|
|
824
423
|
protected getOperationObject(type: "query" | "mutation" | "subscription"): LoomObjectType;
|
|
825
|
-
protected get fieldOptions():
|
|
826
|
-
resolverOptions: ResolvingOptions | undefined;
|
|
827
|
-
weaverContext: WeaverContext;
|
|
828
|
-
};
|
|
424
|
+
protected get fieldOptions(): ConstructorParameters<typeof LoomObjectType>[1];
|
|
829
425
|
static optionsFrom(...inputs: (Resolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): {
|
|
830
426
|
context: WeaverContext | undefined;
|
|
831
427
|
configs: Set<WeaverConfig>;
|
|
832
|
-
middlewares: Set<Middleware
|
|
428
|
+
middlewares: Set<Middleware<any>>;
|
|
833
429
|
resolvers: Set<Resolver>;
|
|
834
430
|
silks: Set<GraphQLSilk<any, any>>;
|
|
835
431
|
weavers: Set<SchemaWeaver>;
|
|
@@ -851,7 +447,7 @@ declare const weave: typeof GraphQLSchemaLoom.weave;
|
|
|
851
447
|
interface EnsureInputOptions {
|
|
852
448
|
fieldName?: string;
|
|
853
449
|
}
|
|
854
|
-
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined, options: EnsureInputOptions | undefined): GraphQLFieldConfigArgumentMap | undefined;
|
|
450
|
+
declare function inputToArgs(input: GraphQLSilk | Record<string, GraphQLSilk> | undefined | void, options: EnsureInputOptions | undefined): GraphQLFieldConfigArgumentMap | undefined;
|
|
855
451
|
declare function ensureInputType(silkOrType: GraphQLType | GraphQLSilk, options: EnsureInputOptions | undefined): GraphQLInputType;
|
|
856
452
|
declare function ensureInputObjectType(object: GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType, options: EnsureInputOptions | undefined): GraphQLInputObjectType;
|
|
857
453
|
|
|
@@ -871,4 +467,4 @@ interface GQLoomExtensionAttribute {
|
|
|
871
467
|
directives?: string[];
|
|
872
468
|
}
|
|
873
469
|
|
|
874
|
-
export {
|
|
470
|
+
export { BaseField, type BatchLoadFn, ChainResolver, type CoreSchemaWeaverConfig, type CoreSchemaWeaverConfigOptions, type DirectiveItem, type DirectiveRecord, EasyDataLoader, Field, FieldChainFactory, FieldFactoryWithUtils, FieldOptions, FieldOrOperation, type GQLoomExtensionAttribute, type GQLoomExtensions, type GlobalWeaverContext, GraphQLFieldOptions, GraphQLSchemaLoom, GraphQLSilk, InferInputI, type ListSilk, LoomObjectType, MayPromise, Middleware, Mutation, MutationChainFactory, MutationFactoryWithChain, MutationOptions, type NonNullSilk, type NullableSilk, OPERATION_OBJECT_NAMES, ObjectChainResolver, OmitInUnion, Operation, Query, QueryChainFactory, QueryFactoryWithChain, QueryOptions, Resolver, type ResolverFactory, ResolverOptions, ResolverOptionsWithExtensions, ResolverPayload, type SchemaWeaver, StandardSchemaV1, Subscription, SubscriptionChainFactory, SubscriptionFactoryWithChain, SubscriptionOptions, type ToExecutorProps, ValueOf, type WeaverConfig, type WeaverContext, capitalize, collectName, collectNames, createField, createMutation, createQuery, createSubscription, deepMerge, defaultSubscriptionResolve, ensureInputObjectType, ensureInputType, ensureInterfaceType, field, getCacheType, getFieldOptions, getGraphQLType, getOperationOptions, getSubscriptionOptions, initWeaverContext, inputToArgs, isSchemaVendorWeaver, isSilk, listSilk, loom, mapValue, markErrorLocation, markLocation, meta, mutation, nonNullSilk, notNullish, nullableSilk, parseSilk, pascalCase, provideWeaverContext, query, resolver, screamingSnakeCase, silk, subscription, toObjMap, tryIn, weave, weaverContext };
|