@gqloom/core 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{context-B-uuklDP.d.cts → context-BbSIyDtg.d.cts} +16 -8
- package/dist/{context-B-uuklDP.d.ts → context-BbSIyDtg.d.ts} +16 -8
- package/dist/context.cjs +2 -1
- package/dist/context.d.cts +1 -3
- package/dist/context.d.ts +1 -3
- package/dist/context.js +2 -1
- package/dist/index.cjs +13 -5
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +13 -5
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ type MayPromise<T> = T | Promise<T>;
|
|
|
4
4
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
5
5
|
type ValueOf<T extends object> = T[keyof T];
|
|
6
6
|
type OmitInUnion<TUnion, TOmit> = TUnion extends infer T ? T extends TOmit ? never : T : never;
|
|
7
|
-
type RequireKeys<T, TKey extends string> = {
|
|
7
|
+
type RequireKeys<T, TKey extends string | number | symbol> = {
|
|
8
8
|
[P in keyof T as P extends TKey ? P : never]-?: T[P];
|
|
9
9
|
} & {
|
|
10
10
|
[P in keyof T as P extends TKey ? never : P]: T[P];
|
|
@@ -277,7 +277,7 @@ declare class FieldChainFactory<TOutput extends GraphQLSilk = never, TInput exte
|
|
|
277
277
|
load<TParent extends GraphQLSilk>(resolve: (parameters: InferInputO<TInput> extends void | undefined ? InferParent<TParent, TDependencies>[] : [
|
|
278
278
|
parent: InferParent<TParent, TDependencies>,
|
|
279
279
|
input: InferInputO<TInput>
|
|
280
|
-
][], payloads: (ResolverPayload | undefined)[]) => MayPromise<
|
|
280
|
+
][], payloads: (ResolverPayload | undefined)[]) => MayPromise<StandardSchemaV1.InferOutput<TOutput>[]>): Field<TParent, TOutput, TInput, TDependencies>;
|
|
281
281
|
}
|
|
282
282
|
type InferParent<TParent extends GraphQLSilk, TDependencies extends string[] | undefined = undefined> = TDependencies extends string[] ? RequireKeys<NonNullable<StandardSchemaV1.InferOutput<TParent>>, TDependencies[number]> : NonNullable<StandardSchemaV1.InferOutput<TParent>>;
|
|
283
283
|
/**
|
|
@@ -666,8 +666,16 @@ interface ResolverPayload<TContext extends object = object, TField extends BaseF
|
|
|
666
666
|
readonly field: TField;
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
-
/**
|
|
670
|
-
|
|
669
|
+
/**
|
|
670
|
+
* The operation of the field:
|
|
671
|
+
* - `field`
|
|
672
|
+
* - `query`
|
|
673
|
+
* - `mutation`
|
|
674
|
+
* - `subscription.resolve`
|
|
675
|
+
* - `subscription.subscribe`
|
|
676
|
+
* - `resolveReference`
|
|
677
|
+
*/
|
|
678
|
+
type MiddlewareOperation = "field" | "query" | "mutation" | "subscription.resolve" | "subscription.subscribe" | "resolveReference";
|
|
671
679
|
interface MiddlewareOptions<TField extends BaseField = BaseField> {
|
|
672
680
|
/** The Output Silk */
|
|
673
681
|
outputSilk: StandardSchemaV1.InferOutput<InferFieldOutput<TField>>;
|
|
@@ -695,7 +703,7 @@ interface Middleware<TField extends BaseField = any> extends Partial<MiddlewareC
|
|
|
695
703
|
(options: CallableMiddlewareOptions<TField>): MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
696
704
|
}
|
|
697
705
|
declare function applyMiddlewares<TField extends BaseField = BaseField>(options: MiddlewareOptions<TField>, resolveFunction: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>, middlewares: Middleware[]): Promise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
698
|
-
declare function filterMiddlewares(operation: MiddlewareOperation, ...middlewareList: (Middleware | Middleware
|
|
706
|
+
declare function filterMiddlewares(operation: MiddlewareOperation, ...middlewareList: (Middleware | Iterable<Middleware> | undefined | null)[]): Middleware[];
|
|
699
707
|
|
|
700
708
|
/**
|
|
701
709
|
* Represents the state of field resolution in a GraphQL query.
|
|
@@ -724,7 +732,7 @@ interface ResolvingFields {
|
|
|
724
732
|
* @param payload - The resolver payload containing the current field resolution context
|
|
725
733
|
* @returns An object containing sets of different field types
|
|
726
734
|
*/
|
|
727
|
-
declare function getResolvingFields(payload: ResolverPayload): ResolvingFields;
|
|
735
|
+
declare function getResolvingFields(payload: Pick<ResolverPayload, "info">): ResolvingFields;
|
|
728
736
|
/**
|
|
729
737
|
* Parses the GraphQL resolve info to extract all requested fields.
|
|
730
738
|
* Returns a Set of field paths where nested fields are represented as 'parent.field'.
|
|
@@ -748,8 +756,8 @@ interface OnlyMemoizationPayload {
|
|
|
748
756
|
* @returns the empty memoization payload
|
|
749
757
|
*/
|
|
750
758
|
declare function onlyMemoization(): OnlyMemoizationPayload;
|
|
751
|
-
declare function isOnlyMemoryPayload(payload:
|
|
752
|
-
declare function getMemoizationMap(payload: OnlyMemoizationPayload | ResolverPayload): WeakMap<WeakKey, any>;
|
|
759
|
+
declare function isOnlyMemoryPayload(payload: OnlyMemoizationPayload | Pick<ResolverPayload, "context">): payload is OnlyMemoizationPayload;
|
|
760
|
+
declare function getMemoizationMap(payload: OnlyMemoizationPayload | Pick<ResolverPayload, "context">): WeakMap<WeakKey, any>;
|
|
753
761
|
interface ContextMemoryContainer {
|
|
754
762
|
[CONTEXT_MAP_KEY]?: WeakMap<WeakKey, any>;
|
|
755
763
|
}
|
|
@@ -4,7 +4,7 @@ type MayPromise<T> = T | Promise<T>;
|
|
|
4
4
|
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
5
5
|
type ValueOf<T extends object> = T[keyof T];
|
|
6
6
|
type OmitInUnion<TUnion, TOmit> = TUnion extends infer T ? T extends TOmit ? never : T : never;
|
|
7
|
-
type RequireKeys<T, TKey extends string> = {
|
|
7
|
+
type RequireKeys<T, TKey extends string | number | symbol> = {
|
|
8
8
|
[P in keyof T as P extends TKey ? P : never]-?: T[P];
|
|
9
9
|
} & {
|
|
10
10
|
[P in keyof T as P extends TKey ? never : P]: T[P];
|
|
@@ -277,7 +277,7 @@ declare class FieldChainFactory<TOutput extends GraphQLSilk = never, TInput exte
|
|
|
277
277
|
load<TParent extends GraphQLSilk>(resolve: (parameters: InferInputO<TInput> extends void | undefined ? InferParent<TParent, TDependencies>[] : [
|
|
278
278
|
parent: InferParent<TParent, TDependencies>,
|
|
279
279
|
input: InferInputO<TInput>
|
|
280
|
-
][], payloads: (ResolverPayload | undefined)[]) => MayPromise<
|
|
280
|
+
][], payloads: (ResolverPayload | undefined)[]) => MayPromise<StandardSchemaV1.InferOutput<TOutput>[]>): Field<TParent, TOutput, TInput, TDependencies>;
|
|
281
281
|
}
|
|
282
282
|
type InferParent<TParent extends GraphQLSilk, TDependencies extends string[] | undefined = undefined> = TDependencies extends string[] ? RequireKeys<NonNullable<StandardSchemaV1.InferOutput<TParent>>, TDependencies[number]> : NonNullable<StandardSchemaV1.InferOutput<TParent>>;
|
|
283
283
|
/**
|
|
@@ -666,8 +666,16 @@ interface ResolverPayload<TContext extends object = object, TField extends BaseF
|
|
|
666
666
|
readonly field: TField;
|
|
667
667
|
}
|
|
668
668
|
|
|
669
|
-
/**
|
|
670
|
-
|
|
669
|
+
/**
|
|
670
|
+
* The operation of the field:
|
|
671
|
+
* - `field`
|
|
672
|
+
* - `query`
|
|
673
|
+
* - `mutation`
|
|
674
|
+
* - `subscription.resolve`
|
|
675
|
+
* - `subscription.subscribe`
|
|
676
|
+
* - `resolveReference`
|
|
677
|
+
*/
|
|
678
|
+
type MiddlewareOperation = "field" | "query" | "mutation" | "subscription.resolve" | "subscription.subscribe" | "resolveReference";
|
|
671
679
|
interface MiddlewareOptions<TField extends BaseField = BaseField> {
|
|
672
680
|
/** The Output Silk */
|
|
673
681
|
outputSilk: StandardSchemaV1.InferOutput<InferFieldOutput<TField>>;
|
|
@@ -695,7 +703,7 @@ interface Middleware<TField extends BaseField = any> extends Partial<MiddlewareC
|
|
|
695
703
|
(options: CallableMiddlewareOptions<TField>): MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
696
704
|
}
|
|
697
705
|
declare function applyMiddlewares<TField extends BaseField = BaseField>(options: MiddlewareOptions<TField>, resolveFunction: () => MayPromise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>, middlewares: Middleware[]): Promise<StandardSchemaV1.InferOutput<InferFieldOutput<TField>>>;
|
|
698
|
-
declare function filterMiddlewares(operation: MiddlewareOperation, ...middlewareList: (Middleware | Middleware
|
|
706
|
+
declare function filterMiddlewares(operation: MiddlewareOperation, ...middlewareList: (Middleware | Iterable<Middleware> | undefined | null)[]): Middleware[];
|
|
699
707
|
|
|
700
708
|
/**
|
|
701
709
|
* Represents the state of field resolution in a GraphQL query.
|
|
@@ -724,7 +732,7 @@ interface ResolvingFields {
|
|
|
724
732
|
* @param payload - The resolver payload containing the current field resolution context
|
|
725
733
|
* @returns An object containing sets of different field types
|
|
726
734
|
*/
|
|
727
|
-
declare function getResolvingFields(payload: ResolverPayload): ResolvingFields;
|
|
735
|
+
declare function getResolvingFields(payload: Pick<ResolverPayload, "info">): ResolvingFields;
|
|
728
736
|
/**
|
|
729
737
|
* Parses the GraphQL resolve info to extract all requested fields.
|
|
730
738
|
* Returns a Set of field paths where nested fields are represented as 'parent.field'.
|
|
@@ -748,8 +756,8 @@ interface OnlyMemoizationPayload {
|
|
|
748
756
|
* @returns the empty memoization payload
|
|
749
757
|
*/
|
|
750
758
|
declare function onlyMemoization(): OnlyMemoizationPayload;
|
|
751
|
-
declare function isOnlyMemoryPayload(payload:
|
|
752
|
-
declare function getMemoizationMap(payload: OnlyMemoizationPayload | ResolverPayload): WeakMap<WeakKey, any>;
|
|
759
|
+
declare function isOnlyMemoryPayload(payload: OnlyMemoizationPayload | Pick<ResolverPayload, "context">): payload is OnlyMemoizationPayload;
|
|
760
|
+
declare function getMemoizationMap(payload: OnlyMemoizationPayload | Pick<ResolverPayload, "context">): WeakMap<WeakKey, any>;
|
|
753
761
|
interface ContextMemoryContainer {
|
|
754
762
|
[CONTEXT_MAP_KEY]?: WeakMap<WeakKey, any>;
|
|
755
763
|
}
|
package/dist/context.cjs
CHANGED
|
@@ -419,7 +419,8 @@ var asyncContextProvider = Object.assign(
|
|
|
419
419
|
"mutation",
|
|
420
420
|
"field",
|
|
421
421
|
"subscription.resolve",
|
|
422
|
-
"subscription.subscribe"
|
|
422
|
+
"subscription.subscribe",
|
|
423
|
+
"resolveReference"
|
|
423
424
|
],
|
|
424
425
|
with: (...keyValues) => {
|
|
425
426
|
return createProvider(...keyValues);
|
package/dist/context.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as OnlyMemoizationPayload, R as ResolverPayload, B as BaseField, v as Middleware, K as ResolvingFields } from './context-
|
|
1
|
+
import { P as OnlyMemoizationPayload, R as ResolverPayload, B as BaseField, v as Middleware, K as ResolvingFields } from './context-BbSIyDtg.cjs';
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
3
|
import 'graphql';
|
|
4
4
|
|
|
@@ -126,8 +126,6 @@ declare const asyncContextProvider: AsyncContextProvider;
|
|
|
126
126
|
/**
|
|
127
127
|
* A hook that analyzes and processes field resolution in a GraphQL query.
|
|
128
128
|
*
|
|
129
|
-
* The hook is memoized to prevent unnecessary recalculations.
|
|
130
|
-
*
|
|
131
129
|
* @returns An object containing sets of different field types,
|
|
132
130
|
* or undefined if no resolver payload is available
|
|
133
131
|
*/
|
package/dist/context.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as OnlyMemoizationPayload, R as ResolverPayload, B as BaseField, v as Middleware, K as ResolvingFields } from './context-
|
|
1
|
+
import { P as OnlyMemoizationPayload, R as ResolverPayload, B as BaseField, v as Middleware, K as ResolvingFields } from './context-BbSIyDtg.js';
|
|
2
2
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
3
3
|
import 'graphql';
|
|
4
4
|
|
|
@@ -126,8 +126,6 @@ declare const asyncContextProvider: AsyncContextProvider;
|
|
|
126
126
|
/**
|
|
127
127
|
* A hook that analyzes and processes field resolution in a GraphQL query.
|
|
128
128
|
*
|
|
129
|
-
* The hook is memoized to prevent unnecessary recalculations.
|
|
130
|
-
*
|
|
131
129
|
* @returns An object containing sets of different field types,
|
|
132
130
|
* or undefined if no resolver payload is available
|
|
133
131
|
*/
|
package/dist/context.js
CHANGED
|
@@ -201,7 +201,8 @@ var asyncContextProvider = Object.assign(
|
|
|
201
201
|
"mutation",
|
|
202
202
|
"field",
|
|
203
203
|
"subscription.resolve",
|
|
204
|
-
"subscription.subscribe"
|
|
204
|
+
"subscription.subscribe",
|
|
205
|
+
"resolveReference"
|
|
205
206
|
],
|
|
206
207
|
with: (...keyValues) => {
|
|
207
208
|
return createProvider(...keyValues);
|
package/dist/index.cjs
CHANGED
|
@@ -148,7 +148,10 @@ function filterMiddlewares(operation, ...middlewareList) {
|
|
|
148
148
|
}, []);
|
|
149
149
|
}
|
|
150
150
|
function ensureArray(value) {
|
|
151
|
-
|
|
151
|
+
if (value != null && typeof value === "object" && Symbol.iterator in value) {
|
|
152
|
+
return Array.from(value);
|
|
153
|
+
}
|
|
154
|
+
return [value];
|
|
152
155
|
}
|
|
153
156
|
|
|
154
157
|
// src/utils/object.ts
|
|
@@ -1812,8 +1815,11 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1812
1815
|
this.resolverOptions.middlewares.push(...middlewares);
|
|
1813
1816
|
return this;
|
|
1814
1817
|
}
|
|
1815
|
-
add(resolver2) {
|
|
1816
|
-
provideWeaverContext(
|
|
1818
|
+
add(resolver2, modifyParent) {
|
|
1819
|
+
provideWeaverContext(
|
|
1820
|
+
() => this.addResolver(resolver2, modifyParent),
|
|
1821
|
+
this.context
|
|
1822
|
+
);
|
|
1817
1823
|
return this;
|
|
1818
1824
|
}
|
|
1819
1825
|
addVendor(weaver) {
|
|
@@ -1856,10 +1862,10 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1856
1862
|
});
|
|
1857
1863
|
return schema;
|
|
1858
1864
|
}
|
|
1859
|
-
addResolver(resolver2) {
|
|
1865
|
+
addResolver(resolver2, modifyParent) {
|
|
1860
1866
|
const resolverOptions = resolver2["~meta"].options;
|
|
1861
1867
|
const parent = resolver2["~meta"].parent;
|
|
1862
|
-
|
|
1868
|
+
let parentObject = (() => {
|
|
1863
1869
|
if (parent == null) return void 0;
|
|
1864
1870
|
let gqlType = getGraphQLType(parent);
|
|
1865
1871
|
if ((0, import_graphql9.isNonNullType)(gqlType)) gqlType = gqlType.ofType;
|
|
@@ -1877,6 +1883,8 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1877
1883
|
})();
|
|
1878
1884
|
if (resolverOptions?.extensions && parentObject)
|
|
1879
1885
|
parentObject.mergeExtensions(resolverOptions.extensions);
|
|
1886
|
+
if (modifyParent != null && parentObject)
|
|
1887
|
+
parentObject = modifyParent(parentObject);
|
|
1880
1888
|
Object.entries(resolver2["~meta"].fields).forEach(([name, field2]) => {
|
|
1881
1889
|
if (field2 === FIELD_HIDDEN) {
|
|
1882
1890
|
if (parentObject == null) return;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-BbSIyDtg.cjs';
|
|
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-BbSIyDtg.cjs';
|
|
3
3
|
import { GraphQLFieldExtensions, GraphQLScalarType, GraphQLObjectType, GraphQLOutputType, GraphQLNullableType, GraphQLList, GraphQLNonNull, GraphQLObjectTypeConfig, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLFieldMap, GraphQLFieldConfig, GraphQLSchemaConfig, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
|
|
4
4
|
|
|
5
5
|
declare function getOperationOptions(resolveOrOptions: ((...args: any) => any) | FieldOptions<any, any, any, any> | QueryOptions<any, any> | MutationOptions<any, any>): any;
|
|
@@ -414,12 +414,12 @@ declare class GraphQLSchemaLoom {
|
|
|
414
414
|
static config(config: CoreSchemaWeaverConfigOptions): CoreSchemaWeaverConfig;
|
|
415
415
|
constructor({ query, mutation, subscription, types }?: SchemaWeaverParameters, context?: WeaverContext);
|
|
416
416
|
use(...middlewares: Middleware[]): this;
|
|
417
|
-
add(resolver: Resolver): this;
|
|
417
|
+
add(resolver: Resolver, modifyParent?: (parent: LoomObjectType) => LoomObjectType): this;
|
|
418
418
|
addVendor(weaver: SchemaWeaver): this;
|
|
419
419
|
addType(silk: GraphQLSilk): this;
|
|
420
420
|
setConfig<TConfig extends WeaverConfig>(config: TConfig): this;
|
|
421
421
|
weaveGraphQLSchema(): GraphQLSchema;
|
|
422
|
-
protected addResolver(resolver: Resolver): this;
|
|
422
|
+
protected addResolver(resolver: Resolver, modifyParent?: (parent: LoomObjectType) => LoomObjectType): this;
|
|
423
423
|
protected getOperationObject(type: "query" | "mutation" | "subscription"): LoomObjectType;
|
|
424
424
|
protected get fieldOptions(): ConstructorParameters<typeof LoomObjectType>[1];
|
|
425
425
|
static optionsFrom(...inputs: (Resolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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-
|
|
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-BbSIyDtg.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-BbSIyDtg.js';
|
|
3
3
|
import { GraphQLFieldExtensions, GraphQLScalarType, GraphQLObjectType, GraphQLOutputType, GraphQLNullableType, GraphQLList, GraphQLNonNull, GraphQLObjectTypeConfig, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLFieldMap, GraphQLFieldConfig, GraphQLSchemaConfig, GraphQLNamedType, GraphQLSchema, GraphQLFieldConfigArgumentMap, GraphQLType, GraphQLInputType, GraphQLInterfaceTypeConfig } from 'graphql';
|
|
4
4
|
|
|
5
5
|
declare function getOperationOptions(resolveOrOptions: ((...args: any) => any) | FieldOptions<any, any, any, any> | QueryOptions<any, any> | MutationOptions<any, any>): any;
|
|
@@ -414,12 +414,12 @@ declare class GraphQLSchemaLoom {
|
|
|
414
414
|
static config(config: CoreSchemaWeaverConfigOptions): CoreSchemaWeaverConfig;
|
|
415
415
|
constructor({ query, mutation, subscription, types }?: SchemaWeaverParameters, context?: WeaverContext);
|
|
416
416
|
use(...middlewares: Middleware[]): this;
|
|
417
|
-
add(resolver: Resolver): this;
|
|
417
|
+
add(resolver: Resolver, modifyParent?: (parent: LoomObjectType) => LoomObjectType): this;
|
|
418
418
|
addVendor(weaver: SchemaWeaver): this;
|
|
419
419
|
addType(silk: GraphQLSilk): this;
|
|
420
420
|
setConfig<TConfig extends WeaverConfig>(config: TConfig): this;
|
|
421
421
|
weaveGraphQLSchema(): GraphQLSchema;
|
|
422
|
-
protected addResolver(resolver: Resolver): this;
|
|
422
|
+
protected addResolver(resolver: Resolver, modifyParent?: (parent: LoomObjectType) => LoomObjectType): this;
|
|
423
423
|
protected getOperationObject(type: "query" | "mutation" | "subscription"): LoomObjectType;
|
|
424
424
|
protected get fieldOptions(): ConstructorParameters<typeof LoomObjectType>[1];
|
|
425
425
|
static optionsFrom(...inputs: (Resolver | Middleware | SchemaWeaver | WeaverConfig | GraphQLSilk)[]): {
|
package/dist/index.js
CHANGED
|
@@ -68,7 +68,10 @@ function filterMiddlewares(operation, ...middlewareList) {
|
|
|
68
68
|
}, []);
|
|
69
69
|
}
|
|
70
70
|
function ensureArray(value) {
|
|
71
|
-
|
|
71
|
+
if (value != null && typeof value === "object" && Symbol.iterator in value) {
|
|
72
|
+
return Array.from(value);
|
|
73
|
+
}
|
|
74
|
+
return [value];
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
// src/utils/object.ts
|
|
@@ -1570,8 +1573,11 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1570
1573
|
this.resolverOptions.middlewares.push(...middlewares);
|
|
1571
1574
|
return this;
|
|
1572
1575
|
}
|
|
1573
|
-
add(resolver2) {
|
|
1574
|
-
provideWeaverContext(
|
|
1576
|
+
add(resolver2, modifyParent) {
|
|
1577
|
+
provideWeaverContext(
|
|
1578
|
+
() => this.addResolver(resolver2, modifyParent),
|
|
1579
|
+
this.context
|
|
1580
|
+
);
|
|
1575
1581
|
return this;
|
|
1576
1582
|
}
|
|
1577
1583
|
addVendor(weaver) {
|
|
@@ -1614,10 +1620,10 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1614
1620
|
});
|
|
1615
1621
|
return schema;
|
|
1616
1622
|
}
|
|
1617
|
-
addResolver(resolver2) {
|
|
1623
|
+
addResolver(resolver2, modifyParent) {
|
|
1618
1624
|
const resolverOptions = resolver2["~meta"].options;
|
|
1619
1625
|
const parent = resolver2["~meta"].parent;
|
|
1620
|
-
|
|
1626
|
+
let parentObject = (() => {
|
|
1621
1627
|
if (parent == null) return void 0;
|
|
1622
1628
|
let gqlType = getGraphQLType(parent);
|
|
1623
1629
|
if (isNonNullType3(gqlType)) gqlType = gqlType.ofType;
|
|
@@ -1635,6 +1641,8 @@ var GraphQLSchemaLoom = class _GraphQLSchemaLoom {
|
|
|
1635
1641
|
})();
|
|
1636
1642
|
if (resolverOptions?.extensions && parentObject)
|
|
1637
1643
|
parentObject.mergeExtensions(resolverOptions.extensions);
|
|
1644
|
+
if (modifyParent != null && parentObject)
|
|
1645
|
+
parentObject = modifyParent(parentObject);
|
|
1638
1646
|
Object.entries(resolver2["~meta"].fields).forEach(([name, field2]) => {
|
|
1639
1647
|
if (field2 === FIELD_HIDDEN) {
|
|
1640
1648
|
if (parentObject == null) return;
|