@fluojs/graphql 1.0.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +153 -17
- package/README.md +158 -17
- package/dist/dataloader/dataloader.d.ts.map +1 -1
- package/dist/dataloader/dataloader.js +2 -3
- package/dist/decorators.d.ts +53 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +123 -1
- package/dist/discovery.d.ts.map +1 -1
- package/dist/discovery.js +13 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/instance-of-patch.d.ts +21 -0
- package/dist/instance-of-patch.d.ts.map +1 -0
- package/dist/instance-of-patch.js +126 -0
- package/dist/metadata.d.ts +21 -1
- package/dist/metadata.d.ts.map +1 -1
- package/dist/metadata.js +68 -7
- package/dist/module.d.ts +14 -10
- package/dist/module.d.ts.map +1 -1
- package/dist/module.js +69 -14
- package/dist/node/graphql-websocket-transport.d.ts +53 -0
- package/dist/node/graphql-websocket-transport.d.ts.map +1 -0
- package/dist/node/graphql-websocket-transport.js +219 -0
- package/dist/pipeline/input-pipeline.js +1 -1
- package/dist/schema/object-field-resolvers.d.ts +18 -0
- package/dist/schema/object-field-resolvers.d.ts.map +1 -0
- package/dist/schema/object-field-resolvers.js +86 -0
- package/dist/schema/schema.d.ts +5 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +75 -39
- package/dist/service.d.ts +10 -12
- package/dist/service.d.ts.map +1 -1
- package/dist/service.js +191 -303
- package/dist/transport/transport.d.ts.map +1 -1
- package/dist/transport/transport.js +1 -1
- package/dist/types.d.ts +40 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +19 -1
- package/package.json +11 -10
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAIV,cAAc,EACd,qBAAqB,EAGtB,MAAM,YAAY,CAAC;AAGpB,KAAK,wBAAwB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,qBAAqB,KAAK,IAAI,CAAC;AAC1F,KAAK,yBAAyB,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,2BAA2B,KAAK,IAAI,CAAC;AACjG,KAAK,wBAAwB,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;AAE1H;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,qBAAqB,CAAC;CACpC;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,KAAK,kBAAkB,GAAG,wBAAwB,CAAC;AACnD,KAAK,mBAAmB,GAAG,yBAAyB,CAAC;AACrD,KAAK,kBAAkB,GAAG,wBAAwB,CAAC;AAoLnD;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAQ9D;AAED;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,qBAAqB,GAAG,mBAAmB,CAE9F;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,qBAAqB,GAAG,mBAAmB,CAEjG;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,qBAAqB,GAAG,mBAAmB,CAErG;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,oBAAoB,GAAG,mBAAmB,CAerG;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,cAAc,SAAI,GAAG,mBAAmB,CAE9D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,cAAc,SAAI,GAAG,mBAAmB,CAE/D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,cAAc,SAAI,GAAG,mBAAmB,CAE5D;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,kBAAkB,CAmBxD"}
|
package/dist/decorators.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { ensureMetadataSymbol } from '@fluojs/core/internal';
|
|
2
|
-
import { argMetadataSymbol, handlerMetadataSymbol, resolverMetadataSymbol } from './metadata.js';
|
|
2
|
+
import { argMetadataSymbol, fieldResolverParameterMetadataSymbol, handlerMetadataSymbol, resolverMetadataSymbol } from './metadata.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Describes the resolver method options contract.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Describes an object field resolver's field name and optional output type override.
|
|
10
|
+
*/
|
|
11
|
+
|
|
8
12
|
ensureMetadataSymbol();
|
|
9
13
|
function getStandardMetadataBag(metadata) {
|
|
10
14
|
return metadata;
|
|
@@ -53,11 +57,28 @@ function defineStandardHandlerMetadata(metadata, propertyKey, handlerMetadata) {
|
|
|
53
57
|
argTypes: handlerMetadata.argTypes,
|
|
54
58
|
fieldName: handlerMetadata.fieldName,
|
|
55
59
|
inputClass: handlerMetadata.inputClass,
|
|
60
|
+
nullable: handlerMetadata.nullable,
|
|
56
61
|
outputType: handlerMetadata.outputType,
|
|
57
62
|
type: handlerMetadata.type
|
|
58
63
|
});
|
|
59
64
|
bag[handlerMetadataSymbol] = map;
|
|
60
65
|
}
|
|
66
|
+
function defineStandardFieldResolverParameterMetadata(metadata, propertyKey, parameterIndex, kind) {
|
|
67
|
+
const bag = getStandardMetadataBag(metadata);
|
|
68
|
+
const current = bag[fieldResolverParameterMetadataSymbol];
|
|
69
|
+
const methods = current ?? new Map();
|
|
70
|
+
const bindings = methods.get(propertyKey) ?? new Map();
|
|
71
|
+
const existing = bindings.get(parameterIndex);
|
|
72
|
+
if (existing) {
|
|
73
|
+
throw new Error(`GraphQL field resolver parameter ${String(parameterIndex)} on ${String(propertyKey)} is already bound to ${existing.kind}.`);
|
|
74
|
+
}
|
|
75
|
+
bindings.set(parameterIndex, {
|
|
76
|
+
index: parameterIndex,
|
|
77
|
+
kind
|
|
78
|
+
});
|
|
79
|
+
methods.set(propertyKey, bindings);
|
|
80
|
+
bag[fieldResolverParameterMetadataSymbol] = methods;
|
|
81
|
+
}
|
|
61
82
|
function defineStandardArgFieldMetadata(metadata, propertyKey, argFieldMetadata) {
|
|
62
83
|
const bag = getStandardMetadataBag(metadata);
|
|
63
84
|
const current = bag[argMetadataSymbol];
|
|
@@ -82,6 +103,42 @@ function createMethodDecorator(type, fieldNameOrOptions) {
|
|
|
82
103
|
};
|
|
83
104
|
return decorator;
|
|
84
105
|
}
|
|
106
|
+
function normalizeFieldResolverMetadata(fieldNameOrOptions) {
|
|
107
|
+
if (typeof fieldNameOrOptions === 'string') {
|
|
108
|
+
return {
|
|
109
|
+
fieldName: fieldNameOrOptions.trim() || undefined,
|
|
110
|
+
type: 'field'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
return {
|
|
114
|
+
argTypes: fieldNameOrOptions?.argTypes,
|
|
115
|
+
fieldName: fieldNameOrOptions?.fieldName?.trim() || undefined,
|
|
116
|
+
inputClass: fieldNameOrOptions?.input,
|
|
117
|
+
nullable: fieldNameOrOptions?.nullable,
|
|
118
|
+
outputType: fieldNameOrOptions?.type,
|
|
119
|
+
type: 'field'
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function createFieldResolverParameterDecorator(kind, parameterIndex) {
|
|
123
|
+
const decoratorName = {
|
|
124
|
+
context: 'Context',
|
|
125
|
+
input: 'Args',
|
|
126
|
+
parent: 'Parent'
|
|
127
|
+
}[kind];
|
|
128
|
+
if (!Number.isSafeInteger(parameterIndex) || parameterIndex < 0) {
|
|
129
|
+
throw new Error(`@${decoratorName}() parameter index must be a non-negative integer.`);
|
|
130
|
+
}
|
|
131
|
+
const decorator = (_value, context) => {
|
|
132
|
+
if (context.private) {
|
|
133
|
+
throw new Error(`@${decoratorName}() cannot be used on private methods.`);
|
|
134
|
+
}
|
|
135
|
+
if (context.static) {
|
|
136
|
+
throw new Error(`@${decoratorName}() cannot be used on static methods.`);
|
|
137
|
+
}
|
|
138
|
+
defineStandardFieldResolverParameterMetadata(context.metadata, context.name, parameterIndex, kind);
|
|
139
|
+
};
|
|
140
|
+
return decorator;
|
|
141
|
+
}
|
|
85
142
|
|
|
86
143
|
/**
|
|
87
144
|
* Resolver.
|
|
@@ -128,6 +185,71 @@ export function Subscription(fieldNameOrOptions) {
|
|
|
128
185
|
return createMethodDecorator('subscription', fieldNameOrOptions);
|
|
129
186
|
}
|
|
130
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Marks a public instance method as the resolver for one field on the object type owned by `@Resolver(typeName)`.
|
|
190
|
+
*
|
|
191
|
+
* @param fieldNameOrOptions Field name or object field resolver options.
|
|
192
|
+
* @returns A TC39 standard method decorator.
|
|
193
|
+
*/
|
|
194
|
+
export function FieldResolver(fieldNameOrOptions) {
|
|
195
|
+
const metadata = normalizeFieldResolverMetadata(fieldNameOrOptions);
|
|
196
|
+
const decorator = (_value, context) => {
|
|
197
|
+
if (context.private) {
|
|
198
|
+
throw new Error('@FieldResolver() cannot be used on private methods.');
|
|
199
|
+
}
|
|
200
|
+
if (context.static) {
|
|
201
|
+
throw new Error('@FieldResolver() cannot be used on static methods.');
|
|
202
|
+
}
|
|
203
|
+
defineStandardHandlerMetadata(context.metadata, context.name, metadata);
|
|
204
|
+
};
|
|
205
|
+
return decorator;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Binds a field resolver method parameter to GraphQL's parent/source object.
|
|
210
|
+
*
|
|
211
|
+
* @remarks
|
|
212
|
+
* TC39 standard decorators do not support parameter-decorator syntax, so this
|
|
213
|
+
* standard method decorator records the parameter index explicitly. The default
|
|
214
|
+
* index is `0`.
|
|
215
|
+
*
|
|
216
|
+
* @param parameterIndex Zero-based method parameter index to receive the parent value.
|
|
217
|
+
* @returns A TC39 standard method decorator.
|
|
218
|
+
*/
|
|
219
|
+
export function Parent(parameterIndex = 0) {
|
|
220
|
+
return createFieldResolverParameterDecorator('parent', parameterIndex);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Binds a field resolver method parameter to the active `GraphQLContext`.
|
|
225
|
+
*
|
|
226
|
+
* @remarks
|
|
227
|
+
* TC39 standard decorators do not support parameter-decorator syntax, so this
|
|
228
|
+
* standard method decorator records the parameter index explicitly. The default
|
|
229
|
+
* index is `1`.
|
|
230
|
+
*
|
|
231
|
+
* @param parameterIndex Zero-based method parameter index to receive the context value.
|
|
232
|
+
* @returns A TC39 standard method decorator.
|
|
233
|
+
*/
|
|
234
|
+
export function Context(parameterIndex = 1) {
|
|
235
|
+
return createFieldResolverParameterDecorator('context', parameterIndex);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Binds a field resolver method parameter to the DTO materialized from GraphQL field arguments.
|
|
240
|
+
*
|
|
241
|
+
* @remarks
|
|
242
|
+
* TC39 standard decorators do not support parameter decorators, so this
|
|
243
|
+
* standard method decorator records the parameter index explicitly. The default
|
|
244
|
+
* index is `0`. Pair it with `@FieldResolver({ input: InputDto })`.
|
|
245
|
+
*
|
|
246
|
+
* @param parameterIndex Zero-based method parameter index to receive the validated input DTO.
|
|
247
|
+
* @returns A TC39 standard method decorator.
|
|
248
|
+
*/
|
|
249
|
+
export function Args(parameterIndex = 0) {
|
|
250
|
+
return createFieldResolverParameterDecorator('input', parameterIndex);
|
|
251
|
+
}
|
|
252
|
+
|
|
131
253
|
/**
|
|
132
254
|
* Arg.
|
|
133
255
|
*
|
package/dist/discovery.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../src/discovery.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAkI3E;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,SAAS,cAAc,EAAE,EAC1C,OAAO,EAAE,oBAAoB,GAC5B,kBAAkB,EAAE,CAoEtB"}
|
package/dist/discovery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getClassDiMetadata } from '@fluojs/core/internal';
|
|
2
|
-
import { getArgFieldMetadataEntries, getResolverHandlerMetadataEntries, getResolverMetadata } from './metadata.js';
|
|
2
|
+
import { getArgFieldMetadataEntries, getFieldResolverParameterMetadataEntries, getResolverHandlerMetadataEntries, getResolverMetadata } from './metadata.js';
|
|
3
3
|
function scopeFromProvider(provider, factoryResolverClass) {
|
|
4
4
|
if (typeof provider === 'function') {
|
|
5
5
|
return getClassDiMetadata(provider)?.scope ?? 'singleton';
|
|
@@ -127,6 +127,16 @@ export function discoverResolverDescriptors(compiledModules, options) {
|
|
|
127
127
|
handlers: getResolverHandlerMetadataEntries(candidate.targetType.prototype).map(entry => {
|
|
128
128
|
const inputClass = entry.metadata.inputClass;
|
|
129
129
|
const argFields = inputClass !== undefined ? getArgFieldMetadataEntries(inputClass.prototype).map(argField => argField.metadata) : [];
|
|
130
|
+
const parameterBindings = getFieldResolverParameterMetadataEntries(candidate.targetType.prototype, entry.propertyKey);
|
|
131
|
+
if (entry.metadata.type !== 'field' && parameterBindings.length > 0) {
|
|
132
|
+
throw new Error(`@Parent() and @Context() can only bind parameters on @FieldResolver() methods; @Args() follows the same rule. ` + `Invalid placement: ${candidate.targetType.name}.${methodKeyToName(entry.propertyKey)}.`);
|
|
133
|
+
}
|
|
134
|
+
if (entry.metadata.type === 'field' && inputClass !== undefined && !parameterBindings.some(binding => binding.kind === 'input')) {
|
|
135
|
+
throw new Error(`@FieldResolver({ input }) requires @Args() on ${candidate.targetType.name}.${methodKeyToName(entry.propertyKey)}.`);
|
|
136
|
+
}
|
|
137
|
+
if (entry.metadata.type === 'field' && inputClass === undefined && parameterBindings.some(binding => binding.kind === 'input')) {
|
|
138
|
+
throw new Error(`@Args() requires @FieldResolver({ input }) on ${candidate.targetType.name}.${methodKeyToName(entry.propertyKey)}.`);
|
|
139
|
+
}
|
|
130
140
|
return {
|
|
131
141
|
argFields,
|
|
132
142
|
argTypes: entry.metadata.argTypes,
|
|
@@ -134,7 +144,9 @@ export function discoverResolverDescriptors(compiledModules, options) {
|
|
|
134
144
|
inputClass,
|
|
135
145
|
methodKey: entry.propertyKey,
|
|
136
146
|
methodName: methodKeyToName(entry.propertyKey),
|
|
147
|
+
nullable: entry.metadata.nullable,
|
|
137
148
|
outputType: entry.metadata.outputType,
|
|
149
|
+
parameterBindings,
|
|
138
150
|
type: entry.metadata.type
|
|
139
151
|
};
|
|
140
152
|
}),
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './dataloader.js';
|
|
2
2
|
export * from './decorators.js';
|
|
3
3
|
export { GraphqlModule } from './module.js';
|
|
4
|
+
export type { ArgFieldMetadata, FieldResolverParameterBindingMetadata, FieldResolverParameterKind, GraphQLContext, GraphqlArgType, GraphqlAsyncModuleOptions, GraphqlListTypeRef, GraphqlModuleOptions, GraphqlRequestContext, GraphqlRequestLimitsOptions, GraphqlRootOutputNamedType, GraphqlRootOutputType, GraphqlScalarTypeName, GraphqlSubscriptionsOptions, GraphqlWebSocketLimitsOptions, GraphqlWebSocketSubscriptionsOptions, ResolverHandlerMetadata, ResolverHandlerType, ResolverMetadata, } from './types.js';
|
|
4
5
|
export { isGraphqlListTypeRef, listOf, } from './types.js';
|
|
5
|
-
export type { ArgFieldMetadata, GraphQLContext, GraphqlArgType, GraphqlListTypeRef, GraphqlModuleOptions, GraphqlRequestLimitsOptions, GraphqlRequestContext, GraphqlRootOutputNamedType, GraphqlRootOutputType, GraphqlScalarTypeName, GraphqlSubscriptionsOptions, GraphqlWebSocketSubscriptionsOptions, ResolverHandlerMetadata, ResolverHandlerType, ResolverMetadata, } from './types.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EACV,gBAAgB,EAChB,qCAAqC,EACrC,0BAA0B,EAC1B,cAAc,EACd,cAAc,EACd,yBAAyB,EACzB,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,2BAA2B,EAC3B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,2BAA2B,EAC3B,6BAA6B,EAC7B,oCAAoC,EACpC,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,MAAM,GACP,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Represents a GraphQL constructor inspected by the private `instanceOf` helper. */
|
|
2
|
+
export type GraphqlConstructor = Function & {
|
|
3
|
+
readonly prototype: {
|
|
4
|
+
readonly [Symbol.toStringTag]?: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/** Represents the private GraphQL `instanceOf` helper signature. */
|
|
8
|
+
export type GraphqlInstanceOf = (value: unknown, constructor: GraphqlConstructor) => boolean;
|
|
9
|
+
/** Represents the mutable private GraphQL module object that owns the helper. */
|
|
10
|
+
export type GraphqlInstanceOfModule = {
|
|
11
|
+
instanceOf: GraphqlInstanceOf;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Installs and releases a cross-realm GraphQL `instanceOf` patch for one module object.
|
|
15
|
+
*
|
|
16
|
+
* @param instanceOfModule The GraphQL module object that owns the `instanceOf` helper.
|
|
17
|
+
* @param allowedObjects The active application's cross-realm GraphQL object allowlist.
|
|
18
|
+
* @returns A one-time release callback for the application's allowlist.
|
|
19
|
+
*/
|
|
20
|
+
export declare function installGraphqlInstanceOfPatch(instanceOfModule: GraphqlInstanceOfModule, allowedObjects: WeakSet<object>): () => void;
|
|
21
|
+
//# sourceMappingURL=instance-of-patch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance-of-patch.d.ts","sourceRoot":"","sources":["../src/instance-of-patch.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG;IAC1C,QAAQ,CAAC,SAAS,EAAE;QAClB,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC;KACxC,CAAC;CACH,CAAC;AAEF,oEAAoE;AACpE,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,kBAAkB,KAAK,OAAO,CAAC;AAE7F,iFAAiF;AACjF,MAAM,MAAM,uBAAuB,GAAG;IACpC,UAAU,EAAE,iBAAiB,CAAC;CAC/B,CAAC;AA0IF;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,uBAAuB,EACzC,cAAc,EAAE,OAAO,CAAC,MAAM,CAAC,GAC9B,MAAM,IAAI,CAmCZ"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/** Represents a GraphQL constructor inspected by the private `instanceOf` helper. */
|
|
2
|
+
|
|
3
|
+
/** Represents the private GraphQL `instanceOf` helper signature. */
|
|
4
|
+
|
|
5
|
+
/** Represents the mutable private GraphQL module object that owns the helper. */
|
|
6
|
+
|
|
7
|
+
const graphqlInstanceOfPatchStateRegistryKey = Symbol.for('@fluojs/graphql.instance-of-patch-state-registry/v1');
|
|
8
|
+
function isGraphqlInstanceOfPatchStateRegistry(value) {
|
|
9
|
+
if (typeof value !== 'object' || value === null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return Reflect.get(value, 'states') instanceof WeakMap;
|
|
13
|
+
}
|
|
14
|
+
function getGraphqlInstanceOfPatchStates() {
|
|
15
|
+
const registeredValue = Reflect.get(globalThis, graphqlInstanceOfPatchStateRegistryKey);
|
|
16
|
+
if (isGraphqlInstanceOfPatchStateRegistry(registeredValue)) {
|
|
17
|
+
return registeredValue.states;
|
|
18
|
+
}
|
|
19
|
+
const registry = {
|
|
20
|
+
states: new WeakMap()
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(globalThis, graphqlInstanceOfPatchStateRegistryKey, {
|
|
23
|
+
configurable: false,
|
|
24
|
+
enumerable: false,
|
|
25
|
+
value: registry,
|
|
26
|
+
writable: false
|
|
27
|
+
});
|
|
28
|
+
return registry.states;
|
|
29
|
+
}
|
|
30
|
+
function createGraphqlInstanceOfPatchState(originalInstanceOf) {
|
|
31
|
+
let patchState;
|
|
32
|
+
const allowedObjectSets = new Set();
|
|
33
|
+
const patchedInstanceOf = (value, constructor) => {
|
|
34
|
+
if (patchState.isEvaluatingDelegate) {
|
|
35
|
+
return isAllowedCrossRealmGraphqlObject(value, constructor, allowedObjectSets);
|
|
36
|
+
}
|
|
37
|
+
patchState.isEvaluatingDelegate = true;
|
|
38
|
+
try {
|
|
39
|
+
try {
|
|
40
|
+
if (patchState.originalInstanceOf(value, constructor)) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
} catch (error) {
|
|
44
|
+
if (isAllowedCrossRealmGraphqlObject(value, constructor, allowedObjectSets)) {
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
return isAllowedCrossRealmGraphqlObject(value, constructor, allowedObjectSets);
|
|
50
|
+
} finally {
|
|
51
|
+
patchState.isEvaluatingDelegate = false;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
patchState = {
|
|
55
|
+
allowedObjectSets,
|
|
56
|
+
isEvaluatingDelegate: false,
|
|
57
|
+
originalInstanceOf,
|
|
58
|
+
patchedInstanceOf
|
|
59
|
+
};
|
|
60
|
+
return patchState;
|
|
61
|
+
}
|
|
62
|
+
function getCrossRealmGraphqlTag(value, constructor) {
|
|
63
|
+
const prototypeTag = constructor.prototype?.[Symbol.toStringTag];
|
|
64
|
+
const className = typeof prototypeTag === 'string' ? prototypeTag : constructor.name;
|
|
65
|
+
if (typeof className !== 'string' || !className.startsWith('GraphQL')) {
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
if (typeof value !== 'object' || value === null) {
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
const valueTag = Reflect.get(value, Symbol.toStringTag);
|
|
72
|
+
if (typeof valueTag === 'string') {
|
|
73
|
+
return valueTag === className ? className : undefined;
|
|
74
|
+
}
|
|
75
|
+
const valueConstructor = Reflect.get(value, 'constructor');
|
|
76
|
+
const valueClassName = typeof valueConstructor === 'object' && valueConstructor !== null || typeof valueConstructor === 'function' ? Reflect.get(valueConstructor, 'name') : undefined;
|
|
77
|
+
return typeof valueClassName === 'string' && valueClassName === className ? className : undefined;
|
|
78
|
+
}
|
|
79
|
+
function isAllowedCrossRealmGraphqlObject(value, constructor, allowedObjectSets) {
|
|
80
|
+
if (typeof value !== 'object' || value === null) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
for (const allowedObjects of allowedObjectSets) {
|
|
84
|
+
if (allowedObjects.has(value)) {
|
|
85
|
+
return getCrossRealmGraphqlTag(value, constructor) !== undefined;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Installs and releases a cross-realm GraphQL `instanceOf` patch for one module object.
|
|
93
|
+
*
|
|
94
|
+
* @param instanceOfModule The GraphQL module object that owns the `instanceOf` helper.
|
|
95
|
+
* @param allowedObjects The active application's cross-realm GraphQL object allowlist.
|
|
96
|
+
* @returns A one-time release callback for the application's allowlist.
|
|
97
|
+
*/
|
|
98
|
+
export function installGraphqlInstanceOfPatch(instanceOfModule, allowedObjects) {
|
|
99
|
+
const patchStates = getGraphqlInstanceOfPatchStates();
|
|
100
|
+
let patchState = patchStates.get(instanceOfModule);
|
|
101
|
+
if (patchState === undefined) {
|
|
102
|
+
patchState = createGraphqlInstanceOfPatchState(instanceOfModule.instanceOf);
|
|
103
|
+
patchStates.set(instanceOfModule, patchState);
|
|
104
|
+
} else if (instanceOfModule.instanceOf !== patchState.patchedInstanceOf) {
|
|
105
|
+
patchState.originalInstanceOf = instanceOfModule.instanceOf;
|
|
106
|
+
}
|
|
107
|
+
instanceOfModule.instanceOf = patchState.patchedInstanceOf;
|
|
108
|
+
patchState.allowedObjectSets.add(allowedObjects);
|
|
109
|
+
let released = false;
|
|
110
|
+
return () => {
|
|
111
|
+
if (released) {
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
released = true;
|
|
115
|
+
patchState.allowedObjectSets.delete(allowedObjects);
|
|
116
|
+
if (patchState.allowedObjectSets.size > 0) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
if (instanceOfModule.instanceOf === patchState.patchedInstanceOf) {
|
|
120
|
+
instanceOfModule.instanceOf = patchState.originalInstanceOf;
|
|
121
|
+
}
|
|
122
|
+
if (patchStates.get(instanceOfModule) === patchState) {
|
|
123
|
+
patchStates.delete(instanceOfModule);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
}
|
package/dist/metadata.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MetadataPropertyKey } from '@fluojs/core';
|
|
2
|
-
import type { ArgFieldMetadata, ResolverHandlerMetadata, ResolverMetadata } from './types.js';
|
|
2
|
+
import type { ArgFieldMetadata, FieldResolverParameterBindingMetadata, ResolverHandlerMetadata, ResolverMetadata } from './types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Define resolver metadata.
|
|
5
5
|
*
|
|
@@ -66,6 +66,22 @@ export declare function getArgFieldMetadataEntries(target: object): Array<{
|
|
|
66
66
|
metadata: ArgFieldMetadata;
|
|
67
67
|
propertyKey: MetadataPropertyKey;
|
|
68
68
|
}>;
|
|
69
|
+
/**
|
|
70
|
+
* Define one positional parameter binding for an object field resolver.
|
|
71
|
+
*
|
|
72
|
+
* @param target Resolver prototype that owns the decorated method.
|
|
73
|
+
* @param propertyKey Decorated method key.
|
|
74
|
+
* @param metadata Positional binding metadata to store.
|
|
75
|
+
*/
|
|
76
|
+
export declare function defineFieldResolverParameterMetadata(target: object, propertyKey: MetadataPropertyKey, metadata: FieldResolverParameterBindingMetadata): void;
|
|
77
|
+
/**
|
|
78
|
+
* Get the positional parameter bindings declared for one resolver method.
|
|
79
|
+
*
|
|
80
|
+
* @param target Resolver prototype that owns the decorated method.
|
|
81
|
+
* @param propertyKey Decorated method key.
|
|
82
|
+
* @returns Parameter bindings ordered by their method parameter index.
|
|
83
|
+
*/
|
|
84
|
+
export declare function getFieldResolverParameterMetadataEntries(target: object, propertyKey: MetadataPropertyKey): FieldResolverParameterBindingMetadata[];
|
|
69
85
|
/**
|
|
70
86
|
* Provides the resolver metadata symbol value.
|
|
71
87
|
*/
|
|
@@ -78,4 +94,8 @@ export declare const handlerMetadataSymbol: symbol;
|
|
|
78
94
|
* Provides the arg metadata symbol value.
|
|
79
95
|
*/
|
|
80
96
|
export declare const argMetadataSymbol: symbol;
|
|
97
|
+
/**
|
|
98
|
+
* Provides the object field-resolver parameter metadata symbol value.
|
|
99
|
+
*/
|
|
100
|
+
export declare const fieldResolverParameterMetadataSymbol: symbol;
|
|
81
101
|
//# sourceMappingURL=metadata.d.ts.map
|
package/dist/metadata.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"metadata.d.ts","sourceRoot":"","sources":["../src/metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGxD,OAAO,KAAK,EACV,gBAAgB,EAChB,qCAAqC,EACrC,uBAAuB,EACvB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAwIpB;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAEvF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAUhF;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,uBAAuB,GAChC,IAAI,CAEN;AAED;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,GAC/B,uBAAuB,GAAG,SAAS,CAUrC;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,GACb,KAAK,CAAC;IAAE,QAAQ,EAAE,uBAAuB,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAOhF;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAEzH;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB,GAAG,gBAAgB,GAAG,SAAS,CAUlH;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,MAAM,GACb,KAAK,CAAC;IAAE,QAAQ,EAAE,gBAAgB,CAAC;IAAC,WAAW,EAAE,mBAAmB,CAAA;CAAE,CAAC,CAEzE;AAED;;;;;;GAMG;AACH,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,EAChC,QAAQ,EAAE,qCAAqC,GAC9C,IAAI,CAKN;AAED;;;;;;GAMG;AACH,wBAAgB,wCAAwC,CACtD,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,mBAAmB,GAC/B,qCAAqC,EAAE,CAczC;AAED;;GAEG;AACH,eAAO,MAAM,sBAAsB,QAA8B,CAAC;AAClE;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAA6B,CAAC;AAChE;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAA8B,CAAC;AAC7D;;GAEG;AACH,eAAO,MAAM,oCAAoC,QAA4C,CAAC"}
|
package/dist/metadata.js
CHANGED
|
@@ -3,9 +3,11 @@ void ensureSymbolMetadataPolyfill();
|
|
|
3
3
|
const standardResolverMetadataKey = Symbol.for('fluo.graphql.standard.resolver');
|
|
4
4
|
const standardHandlerMetadataKey = Symbol.for('fluo.graphql.standard.handler');
|
|
5
5
|
const standardArgFieldMetadataKey = Symbol.for('fluo.graphql.standard.arg-field');
|
|
6
|
+
const standardFieldResolverParameterMetadataKey = Symbol.for('fluo.graphql.standard.field-resolver-parameter');
|
|
6
7
|
const resolverMetadataStore = new WeakMap();
|
|
7
8
|
const handlerMetadataStore = new WeakMap();
|
|
8
9
|
const argFieldMetadataStore = new WeakMap();
|
|
10
|
+
const fieldResolverParameterMetadataStore = new WeakMap();
|
|
9
11
|
function cloneResolverMetadata(metadata) {
|
|
10
12
|
return {
|
|
11
13
|
typeName: metadata.typeName
|
|
@@ -16,10 +18,17 @@ function cloneHandlerMetadata(metadata) {
|
|
|
16
18
|
argTypes: metadata.argTypes,
|
|
17
19
|
fieldName: metadata.fieldName,
|
|
18
20
|
inputClass: metadata.inputClass,
|
|
21
|
+
nullable: metadata.nullable,
|
|
19
22
|
outputType: metadata.outputType,
|
|
20
23
|
type: metadata.type
|
|
21
24
|
};
|
|
22
25
|
}
|
|
26
|
+
function cloneFieldResolverParameterMetadata(metadata) {
|
|
27
|
+
return {
|
|
28
|
+
index: metadata.index,
|
|
29
|
+
kind: metadata.kind
|
|
30
|
+
};
|
|
31
|
+
}
|
|
23
32
|
function cloneArgFieldMetadata(metadata) {
|
|
24
33
|
return {
|
|
25
34
|
argName: metadata.argName,
|
|
@@ -39,6 +48,9 @@ function getStandardHandlerMap(target) {
|
|
|
39
48
|
function getStandardArgFieldMap(target) {
|
|
40
49
|
return getStandardConstructorMetadataBag(target)?.[standardArgFieldMetadataKey];
|
|
41
50
|
}
|
|
51
|
+
function getStandardFieldResolverParameterMap(target) {
|
|
52
|
+
return getStandardConstructorMetadataBag(target)?.[standardFieldResolverParameterMetadataKey];
|
|
53
|
+
}
|
|
42
54
|
function getOrCreateHandlerMetadataMap(target) {
|
|
43
55
|
let map = handlerMetadataStore.get(target);
|
|
44
56
|
if (!map) {
|
|
@@ -55,6 +67,14 @@ function getOrCreateArgFieldMetadataMap(target) {
|
|
|
55
67
|
}
|
|
56
68
|
return map;
|
|
57
69
|
}
|
|
70
|
+
function getOrCreateFieldResolverParameterMetadataMap(target) {
|
|
71
|
+
let map = fieldResolverParameterMetadataStore.get(target);
|
|
72
|
+
if (!map) {
|
|
73
|
+
map = new Map();
|
|
74
|
+
fieldResolverParameterMetadataStore.set(target, map);
|
|
75
|
+
}
|
|
76
|
+
return map;
|
|
77
|
+
}
|
|
58
78
|
function getMergedMetadataEntries(target, stored, standard, resolve) {
|
|
59
79
|
const storedMap = stored ?? new Map();
|
|
60
80
|
const standardMap = standard ?? new Map();
|
|
@@ -84,10 +104,11 @@ export function defineResolverMetadata(target, metadata) {
|
|
|
84
104
|
export function getResolverMetadata(target) {
|
|
85
105
|
const stored = resolverMetadataStore.get(target);
|
|
86
106
|
const standard = getStandardResolverMetadata(target);
|
|
87
|
-
|
|
107
|
+
const metadata = stored ?? standard;
|
|
108
|
+
if (!metadata) {
|
|
88
109
|
return undefined;
|
|
89
110
|
}
|
|
90
|
-
return cloneResolverMetadata(
|
|
111
|
+
return cloneResolverMetadata(metadata);
|
|
91
112
|
}
|
|
92
113
|
|
|
93
114
|
/**
|
|
@@ -111,10 +132,11 @@ export function defineResolverHandlerMetadata(target, propertyKey, metadata) {
|
|
|
111
132
|
export function getResolverHandlerMetadata(target, propertyKey) {
|
|
112
133
|
const stored = handlerMetadataStore.get(target)?.get(propertyKey);
|
|
113
134
|
const standard = getStandardHandlerMap(target)?.get(propertyKey);
|
|
114
|
-
|
|
135
|
+
const metadata = stored ?? standard;
|
|
136
|
+
if (!metadata) {
|
|
115
137
|
return undefined;
|
|
116
138
|
}
|
|
117
|
-
return cloneHandlerMetadata(
|
|
139
|
+
return cloneHandlerMetadata(metadata);
|
|
118
140
|
}
|
|
119
141
|
|
|
120
142
|
/**
|
|
@@ -148,10 +170,11 @@ export function defineArgFieldMetadata(target, propertyKey, metadata) {
|
|
|
148
170
|
export function getArgFieldMetadata(target, propertyKey) {
|
|
149
171
|
const stored = argFieldMetadataStore.get(target)?.get(propertyKey);
|
|
150
172
|
const standard = getStandardArgFieldMap(target)?.get(propertyKey);
|
|
151
|
-
|
|
173
|
+
const metadata = stored ?? standard;
|
|
174
|
+
if (!metadata) {
|
|
152
175
|
return undefined;
|
|
153
176
|
}
|
|
154
|
-
return cloneArgFieldMetadata(
|
|
177
|
+
return cloneArgFieldMetadata(metadata);
|
|
155
178
|
}
|
|
156
179
|
|
|
157
180
|
/**
|
|
@@ -164,6 +187,40 @@ export function getArgFieldMetadataEntries(target) {
|
|
|
164
187
|
return getMergedMetadataEntries(target, argFieldMetadataStore.get(target), getStandardArgFieldMap(target), getArgFieldMetadata);
|
|
165
188
|
}
|
|
166
189
|
|
|
190
|
+
/**
|
|
191
|
+
* Define one positional parameter binding for an object field resolver.
|
|
192
|
+
*
|
|
193
|
+
* @param target Resolver prototype that owns the decorated method.
|
|
194
|
+
* @param propertyKey Decorated method key.
|
|
195
|
+
* @param metadata Positional binding metadata to store.
|
|
196
|
+
*/
|
|
197
|
+
export function defineFieldResolverParameterMetadata(target, propertyKey, metadata) {
|
|
198
|
+
const methods = getOrCreateFieldResolverParameterMetadataMap(target);
|
|
199
|
+
const bindings = methods.get(propertyKey) ?? new Map();
|
|
200
|
+
bindings.set(metadata.index, cloneFieldResolverParameterMetadata(metadata));
|
|
201
|
+
methods.set(propertyKey, bindings);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Get the positional parameter bindings declared for one resolver method.
|
|
206
|
+
*
|
|
207
|
+
* @param target Resolver prototype that owns the decorated method.
|
|
208
|
+
* @param propertyKey Decorated method key.
|
|
209
|
+
* @returns Parameter bindings ordered by their method parameter index.
|
|
210
|
+
*/
|
|
211
|
+
export function getFieldResolverParameterMetadataEntries(target, propertyKey) {
|
|
212
|
+
const stored = fieldResolverParameterMetadataStore.get(target)?.get(propertyKey);
|
|
213
|
+
const standard = getStandardFieldResolverParameterMap(target)?.get(propertyKey);
|
|
214
|
+
const merged = new Map();
|
|
215
|
+
for (const [index, metadata] of standard ?? []) {
|
|
216
|
+
merged.set(index, cloneFieldResolverParameterMetadata(metadata));
|
|
217
|
+
}
|
|
218
|
+
for (const [index, metadata] of stored ?? []) {
|
|
219
|
+
merged.set(index, cloneFieldResolverParameterMetadata(metadata));
|
|
220
|
+
}
|
|
221
|
+
return Array.from(merged.values()).sort((left, right) => left.index - right.index);
|
|
222
|
+
}
|
|
223
|
+
|
|
167
224
|
/**
|
|
168
225
|
* Provides the resolver metadata symbol value.
|
|
169
226
|
*/
|
|
@@ -175,4 +232,8 @@ export const handlerMetadataSymbol = standardHandlerMetadataKey;
|
|
|
175
232
|
/**
|
|
176
233
|
* Provides the arg metadata symbol value.
|
|
177
234
|
*/
|
|
178
|
-
export const argMetadataSymbol = standardArgFieldMetadataKey;
|
|
235
|
+
export const argMetadataSymbol = standardArgFieldMetadataKey;
|
|
236
|
+
/**
|
|
237
|
+
* Provides the object field-resolver parameter metadata symbol value.
|
|
238
|
+
*/
|
|
239
|
+
export const fieldResolverParameterMetadataSymbol = standardFieldResolverParameterMetadataKey;
|
package/dist/module.d.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { InjectionToken } from '@fluojs/core';
|
|
2
2
|
import { type ModuleType } from '@fluojs/runtime';
|
|
3
|
-
import type { GraphqlModuleOptions } from './types.js';
|
|
4
|
-
/**
|
|
5
|
-
* Creates GraphQL runtime providers for module-level options and lifecycle wiring.
|
|
6
|
-
*
|
|
7
|
-
* @param options GraphQL module options used by the lifecycle service and endpoint controller.
|
|
8
|
-
* @returns Provider definitions that register only the internal options token and GraphQL lifecycle service; this helper
|
|
9
|
-
* does not register `GraphqlEndpointController` or mount the `/graphql` endpoint by itself.
|
|
10
|
-
*/
|
|
11
|
-
export declare function createGraphqlProviders(options: GraphqlModuleOptions): Provider[];
|
|
3
|
+
import type { GraphqlAsyncModuleOptions, GraphqlModuleOptions } from './types.js';
|
|
12
4
|
/**
|
|
13
5
|
* Represents the graphql module.
|
|
14
6
|
*/
|
|
@@ -21,5 +13,17 @@ export declare class GraphqlModule {
|
|
|
21
13
|
* module path (not `createGraphqlProviders(...)` alone) when the application should expose `/graphql`.
|
|
22
14
|
*/
|
|
23
15
|
static forRoot(options?: GraphqlModuleOptions): ModuleType;
|
|
16
|
+
/**
|
|
17
|
+
* Registers GraphQL from options resolved by explicitly injected application dependencies.
|
|
18
|
+
*
|
|
19
|
+
* The factory runs once in each application context. Only `inject` and `useFactory` are
|
|
20
|
+
* supported; NestJS-style `imports`, `useClass`, `useExisting`, and implicit discovery are rejected.
|
|
21
|
+
*
|
|
22
|
+
* @param options Injected dependency tokens and the factory that resolves GraphQL options.
|
|
23
|
+
* @returns A module definition that resolves GraphQL configuration before endpoint lifecycle wiring begins.
|
|
24
|
+
*
|
|
25
|
+
* @throws {TypeError} When the options shape requests unsupported registration behavior.
|
|
26
|
+
*/
|
|
27
|
+
static forRootAsync<const TTokens extends readonly InjectionToken[]>(options: GraphqlAsyncModuleOptions<TTokens>): ModuleType;
|
|
24
28
|
}
|
|
25
29
|
//# sourceMappingURL=module.d.ts.map
|
package/dist/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAKhE,OAAO,KAAK,EAAE,yBAAyB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAiDlF;;GAEG;AACH,qBAAa,aAAa;IACxB;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,UAAU;IAa9D;;;;;;;;;;OAUG;IACH,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,OAAO,SAAS,SAAS,cAAc,EAAE,EACjE,OAAO,EAAE,yBAAyB,CAAC,OAAO,CAAC,GAC1C,UAAU;CA4Bd"}
|