graphql-modules 3.1.2-alpha-20260121023952-c6236f99446644c787494ddb1a9a973180bab70e → 3.1.2-alpha-20260121024633-8af430e29a180a1d00c50c4bf74d342b3518267c

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.
Files changed (161) hide show
  1. package/cjs/application/apollo.js +81 -0
  2. package/cjs/application/application.js +149 -0
  3. package/cjs/application/context.js +144 -0
  4. package/cjs/application/di.js +48 -0
  5. package/cjs/application/execution.js +42 -0
  6. package/cjs/application/operation-controller.js +16 -0
  7. package/cjs/application/subscription.js +54 -0
  8. package/cjs/application/tokens.js +20 -0
  9. package/cjs/application/types.js +0 -0
  10. package/cjs/di/decorators.js +78 -0
  11. package/cjs/di/errors.js +87 -0
  12. package/cjs/di/forward-ref.js +26 -0
  13. package/cjs/di/index.js +19 -0
  14. package/cjs/di/injector.js +173 -0
  15. package/cjs/di/metadata.js +22 -0
  16. package/cjs/di/providers.js +60 -0
  17. package/cjs/di/registry.js +44 -0
  18. package/cjs/di/resolution.js +166 -0
  19. package/cjs/di/utils.js +44 -0
  20. package/cjs/index.js +31 -0
  21. package/cjs/module/factory.js +71 -0
  22. package/cjs/module/metadata.js +110 -0
  23. package/cjs/module/module.js +27 -0
  24. package/cjs/module/resolvers.js +341 -0
  25. package/cjs/module/tokens.js +21 -0
  26. package/cjs/module/type-defs.js +24 -0
  27. package/cjs/module/types.js +0 -0
  28. package/cjs/package.json +1 -0
  29. package/cjs/shared/di.js +0 -0
  30. package/cjs/shared/errors.js +82 -0
  31. package/cjs/shared/gql.js +12 -0
  32. package/cjs/shared/middleware.js +109 -0
  33. package/cjs/shared/types.js +0 -0
  34. package/cjs/shared/utils.js +115 -0
  35. package/cjs/testing/di.js +9 -0
  36. package/cjs/testing/graphql.js +10 -0
  37. package/cjs/testing/index.js +17 -0
  38. package/cjs/testing/test-application.js +65 -0
  39. package/cjs/testing/test-injector.js +22 -0
  40. package/cjs/testing/test-module.js +270 -0
  41. package/esm/application/apollo.js +77 -0
  42. package/esm/application/application.js +146 -0
  43. package/esm/application/context.js +140 -0
  44. package/esm/application/di.js +42 -0
  45. package/esm/application/execution.js +39 -0
  46. package/esm/application/operation-controller.js +13 -0
  47. package/esm/application/subscription.js +51 -0
  48. package/esm/application/tokens.js +17 -0
  49. package/esm/application/types.js +0 -0
  50. package/esm/di/decorators.js +72 -0
  51. package/esm/di/errors.js +79 -0
  52. package/esm/di/forward-ref.js +22 -0
  53. package/esm/di/index.js +4 -0
  54. package/esm/di/injector.js +168 -0
  55. package/esm/di/metadata.js +17 -0
  56. package/esm/di/providers.js +50 -0
  57. package/esm/di/registry.js +40 -0
  58. package/esm/di/resolution.js +159 -0
  59. package/esm/di/utils.js +36 -0
  60. package/esm/index.js +16 -0
  61. package/esm/module/factory.js +68 -0
  62. package/esm/module/metadata.js +107 -0
  63. package/esm/module/module.js +24 -0
  64. package/esm/module/resolvers.js +337 -0
  65. package/esm/module/tokens.js +18 -0
  66. package/esm/module/type-defs.js +21 -0
  67. package/esm/module/types.js +0 -0
  68. package/esm/shared/di.js +0 -0
  69. package/esm/shared/errors.js +69 -0
  70. package/esm/shared/gql.js +9 -0
  71. package/esm/shared/middleware.js +103 -0
  72. package/esm/shared/types.js +0 -0
  73. package/esm/shared/utils.js +101 -0
  74. package/esm/testing/di.js +6 -0
  75. package/esm/testing/graphql.js +7 -0
  76. package/esm/testing/index.js +14 -0
  77. package/esm/testing/test-application.js +62 -0
  78. package/esm/testing/test-injector.js +18 -0
  79. package/esm/testing/test-module.js +266 -0
  80. package/package.json +29 -9
  81. package/typings/application/apollo.d.ts +22 -0
  82. package/typings/application/application.d.ts +32 -0
  83. package/typings/application/context.d.ts +24 -0
  84. package/typings/application/di.d.ts +22 -0
  85. package/typings/application/execution.d.ts +8 -0
  86. package/typings/application/operation-controller.d.ts +5 -0
  87. package/typings/application/subscription.d.ts +8 -0
  88. package/typings/application/tokens.d.ts +17 -0
  89. package/typings/application/types.d.ts +130 -0
  90. package/typings/di/decorators.d.ts +11 -0
  91. package/typings/di/errors.d.ts +16 -0
  92. package/typings/di/forward-ref.d.ts +7 -0
  93. package/typings/di/index.d.ts +5 -0
  94. package/typings/di/injector.d.ts +50 -0
  95. package/typings/di/metadata.d.ts +12 -0
  96. package/typings/di/providers.d.ts +44 -0
  97. package/typings/di/registry.d.ts +11 -0
  98. package/typings/di/resolution.d.ts +63 -0
  99. package/typings/di/utils.d.ts +8 -0
  100. package/typings/index.d.ts +13 -0
  101. package/typings/module/factory.d.ts +16 -0
  102. package/typings/module/metadata.d.ts +12 -0
  103. package/typings/module/module.d.ts +22 -0
  104. package/typings/module/resolvers.d.ts +13 -0
  105. package/typings/module/tokens.d.ts +18 -0
  106. package/typings/module/type-defs.d.ts +7 -0
  107. package/typings/module/types.d.ts +51 -0
  108. package/typings/shared/di.d.ts +3 -0
  109. package/typings/shared/errors.d.ts +36 -0
  110. package/typings/shared/gql.d.ts +2 -0
  111. package/typings/shared/middleware.d.ts +21 -0
  112. package/typings/shared/types.d.ts +22 -0
  113. package/typings/shared/utils.d.ts +12 -0
  114. package/typings/testing/di.d.ts +2 -0
  115. package/typings/testing/graphql.d.ts +14 -0
  116. package/typings/testing/index.d.ts +14 -0
  117. package/typings/testing/test-application.d.ts +2 -0
  118. package/typings/testing/test-injector.d.ts +4 -0
  119. package/typings/testing/test-module.d.ts +10 -0
  120. package/LICENSE.md +0 -21
  121. package/index.js +0 -2359
  122. package/index.mjs +0 -2344
  123. /package/{application/apollo.d.ts → typings/application/apollo.d.cts} +0 -0
  124. /package/{application/application.d.ts → typings/application/application.d.cts} +0 -0
  125. /package/{application/context.d.ts → typings/application/context.d.cts} +0 -0
  126. /package/{application/di.d.ts → typings/application/di.d.cts} +0 -0
  127. /package/{application/execution.d.ts → typings/application/execution.d.cts} +0 -0
  128. /package/{application/operation-controller.d.ts → typings/application/operation-controller.d.cts} +0 -0
  129. /package/{application/subscription.d.ts → typings/application/subscription.d.cts} +0 -0
  130. /package/{application/tokens.d.ts → typings/application/tokens.d.cts} +0 -0
  131. /package/{application/types.d.ts → typings/application/types.d.cts} +0 -0
  132. /package/{di/decorators.d.ts → typings/di/decorators.d.cts} +0 -0
  133. /package/{di/errors.d.ts → typings/di/errors.d.cts} +0 -0
  134. /package/{di/forward-ref.d.ts → typings/di/forward-ref.d.cts} +0 -0
  135. /package/{di/index.d.ts → typings/di/index.d.cts} +0 -0
  136. /package/{di/injector.d.ts → typings/di/injector.d.cts} +0 -0
  137. /package/{di/metadata.d.ts → typings/di/metadata.d.cts} +0 -0
  138. /package/{di/providers.d.ts → typings/di/providers.d.cts} +0 -0
  139. /package/{di/registry.d.ts → typings/di/registry.d.cts} +0 -0
  140. /package/{di/resolution.d.ts → typings/di/resolution.d.cts} +0 -0
  141. /package/{di/utils.d.ts → typings/di/utils.d.cts} +0 -0
  142. /package/{index.d.ts → typings/index.d.cts} +0 -0
  143. /package/{module/factory.d.ts → typings/module/factory.d.cts} +0 -0
  144. /package/{module/metadata.d.ts → typings/module/metadata.d.cts} +0 -0
  145. /package/{module/module.d.ts → typings/module/module.d.cts} +0 -0
  146. /package/{module/resolvers.d.ts → typings/module/resolvers.d.cts} +0 -0
  147. /package/{module/tokens.d.ts → typings/module/tokens.d.cts} +0 -0
  148. /package/{module/type-defs.d.ts → typings/module/type-defs.d.cts} +0 -0
  149. /package/{module/types.d.ts → typings/module/types.d.cts} +0 -0
  150. /package/{shared/di.d.ts → typings/shared/di.d.cts} +0 -0
  151. /package/{shared/errors.d.ts → typings/shared/errors.d.cts} +0 -0
  152. /package/{shared/gql.d.ts → typings/shared/gql.d.cts} +0 -0
  153. /package/{shared/middleware.d.ts → typings/shared/middleware.d.cts} +0 -0
  154. /package/{shared/types.d.ts → typings/shared/types.d.cts} +0 -0
  155. /package/{shared/utils.d.ts → typings/shared/utils.d.cts} +0 -0
  156. /package/{testing/di.d.ts → typings/testing/di.d.cts} +0 -0
  157. /package/{testing/graphql.d.ts → typings/testing/graphql.d.cts} +0 -0
  158. /package/{testing/index.d.ts → typings/testing/index.d.cts} +0 -0
  159. /package/{testing/test-application.d.ts → typings/testing/test-application.d.cts} +0 -0
  160. /package/{testing/test-injector.d.ts → typings/testing/test-injector.d.cts} +0 -0
  161. /package/{testing/test-module.d.ts → typings/testing/test-module.d.cts} +0 -0
@@ -0,0 +1,36 @@
1
+ import { ID } from './types';
2
+ declare const ModuleNonUniqueIdError_base: ErrorConstructor;
3
+ export declare class ModuleNonUniqueIdError extends ModuleNonUniqueIdError_base {
4
+ constructor(message: string, ...rest: string[]);
5
+ }
6
+ declare const ModuleDuplicatedError_base: ErrorConstructor;
7
+ export declare class ModuleDuplicatedError extends ModuleDuplicatedError_base {
8
+ constructor(message: string, ...rest: string[]);
9
+ }
10
+ declare const ExtraResolverError_base: ErrorConstructor;
11
+ export declare class ExtraResolverError extends ExtraResolverError_base {
12
+ constructor(message: string, ...rest: string[]);
13
+ }
14
+ declare const ExtraMiddlewareError_base: ErrorConstructor;
15
+ export declare class ExtraMiddlewareError extends ExtraMiddlewareError_base {
16
+ constructor(message: string, ...rest: string[]);
17
+ }
18
+ declare const ResolverDuplicatedError_base: ErrorConstructor;
19
+ export declare class ResolverDuplicatedError extends ResolverDuplicatedError_base {
20
+ constructor(message: string, ...rest: string[]);
21
+ }
22
+ declare const ResolverInvalidError_base: ErrorConstructor;
23
+ export declare class ResolverInvalidError extends ResolverInvalidError_base {
24
+ constructor(message: string, ...rest: string[]);
25
+ }
26
+ declare const NonDocumentNodeError_base: ErrorConstructor;
27
+ export declare class NonDocumentNodeError extends NonDocumentNodeError_base {
28
+ constructor(message: string, ...rest: string[]);
29
+ }
30
+ export declare function useLocation({ dirname, id }: {
31
+ id: ID;
32
+ dirname?: string;
33
+ }): string;
34
+ export declare function ExtendableBuiltin<T extends Function>(cls: T): T;
35
+ export declare function composeMessage(...lines: string[]): string;
36
+ export {};
@@ -0,0 +1,2 @@
1
+ import { DocumentNode } from 'graphql';
2
+ export declare function gql(literals: ReadonlyArray<string> | Readonly<string>): DocumentNode;
@@ -0,0 +1,21 @@
1
+ import { GraphQLResolveInfo } from 'graphql';
2
+ import { ModuleMetadata } from './../module/metadata';
3
+ export type Next<T = any> = () => Promise<T>;
4
+ export type Middleware<TContext = MiddlewareContext> = (context: TContext, next: Next) => Promise<any>;
5
+ export declare function compose<TContext>(middleware: Array<Middleware<TContext>>): (context: TContext, next: Next) => Promise<any>;
6
+ export interface MiddlewareContext {
7
+ root: any;
8
+ args: {
9
+ [argName: string]: any;
10
+ };
11
+ context: GraphQLModules.ModuleContext;
12
+ info: GraphQLResolveInfo;
13
+ }
14
+ export type MiddlewareMap = {
15
+ [type: string]: {
16
+ [field: string]: Middleware[];
17
+ };
18
+ };
19
+ export declare function createMiddleware(path: string[], middlewareMap?: MiddlewareMap): (context: MiddlewareContext, next: Next) => Promise<any>;
20
+ export declare function mergeMiddlewareMaps(app: MiddlewareMap, mod: MiddlewareMap): MiddlewareMap;
21
+ export declare function validateMiddlewareMap(middlewareMap: MiddlewareMap, metadata: ModuleMetadata): void;
@@ -0,0 +1,22 @@
1
+ import { GraphQLFieldResolver, GraphQLTypeResolver } from 'graphql';
2
+ import { Injector } from '../di';
3
+ export type ID = string;
4
+ export type Nil = undefined | null;
5
+ export type Maybe<T> = T | Nil;
6
+ export type Plural<T> = T | T[];
7
+ export type Single<T> = T extends Array<infer R> ? R : T;
8
+ export type ValueOrPromise<T> = T | Promise<T>;
9
+ export type ResolveFn<TContext = GraphQLModules.Context> = GraphQLFieldResolver<any, TContext, Record<string, any>>;
10
+ export type ResolveTypeFn<TContext = GraphQLModules.Context> = GraphQLTypeResolver<any, TContext>;
11
+ declare global {
12
+ namespace GraphQLModules {
13
+ type ModuleContext = {
14
+ injector: Injector;
15
+ moduleId: ID;
16
+ } & GlobalContext;
17
+ type AppContext = Omit<ModuleContext, 'moduleId'>;
18
+ type Context = ModuleContext;
19
+ interface GlobalContext {
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,12 @@
1
+ export declare function flatten<T>(arr: T[]): T extends (infer A)[] ? A[] : T[];
2
+ export declare function isDefined<T>(val: T | null | undefined): val is T;
3
+ export declare function isNil<T>(val: T | null | undefined): val is null | undefined;
4
+ export declare function isObject(val: any): boolean;
5
+ export declare function isPrimitive(val: any): val is number | string | boolean | symbol | bigint;
6
+ export declare function isAsyncIterable(obj: any): obj is AsyncIterableIterator<any>;
7
+ export declare function tapAsyncIterator<T, TAsyncIterableIterator extends AsyncIterableIterator<T>>(iterable: TAsyncIterableIterator, doneCallback: () => void): TAsyncIterableIterator;
8
+ export declare function once(cb: () => void): () => void;
9
+ export declare function share<T, A>(factory: (arg?: A) => T): (arg?: A) => T;
10
+ export declare function uniqueId(isNotUsed: (id: string) => boolean): string;
11
+ export declare function isNotSchema<T>(obj: any): obj is T;
12
+ export declare function merge<S extends object, T extends object>(source: S, target: T): S & T;
@@ -0,0 +1,2 @@
1
+ import { ValueProvider } from './../di/providers';
2
+ export declare function provideEmpty<T = any>(token: ValueProvider<T>['provide']): ValueProvider<T>;
@@ -0,0 +1,14 @@
1
+ import type { DocumentNode, ExecutionArgs, ExecutionResult } from 'graphql';
2
+ import type { TypedDocumentNode } from '@graphql-typed-document-node/core';
3
+ import type { Application, OperationController } from '../application/types';
4
+ import type { ValueOrPromise } from '../shared/types';
5
+ export declare function execute<TResult = {
6
+ [key: string]: any;
7
+ }, TVariables = {
8
+ [key: string]: any;
9
+ }>(app: Application, inputs: Omit<ExecutionArgs, 'schema'> & {
10
+ document: DocumentNode | TypedDocumentNode<TResult, TVariables>;
11
+ variableValues?: TVariables;
12
+ }, options?: {
13
+ controller?: OperationController;
14
+ }): ValueOrPromise<ExecutionResult<TResult>>;
@@ -0,0 +1,14 @@
1
+ import { mockApplication } from './test-application';
2
+ import { testModule, mockModule } from './test-module';
3
+ import { testInjector, readProviderOptions } from './test-injector';
4
+ import { execute } from './graphql';
5
+ import { provideEmpty } from './di';
6
+ export declare const testkit: {
7
+ mockApplication: typeof mockApplication;
8
+ mockModule: typeof mockModule;
9
+ testModule: typeof testModule;
10
+ testInjector: typeof testInjector;
11
+ readProviderOptions: typeof readProviderOptions;
12
+ provideEmpty: typeof provideEmpty;
13
+ execute: typeof execute;
14
+ };
@@ -0,0 +1,2 @@
1
+ import { Application, MockedApplication } from '../application/types';
2
+ export declare function mockApplication(app: Application): MockedApplication;
@@ -0,0 +1,4 @@
1
+ import { Injector } from '../di/injector';
2
+ import { Provider, TypeProvider } from '../di/providers';
3
+ export declare function testInjector(providers: Provider[]): Injector;
4
+ export declare function readProviderOptions<T>(provider: TypeProvider<T>): import("../di/providers").ProviderOptions | undefined;
@@ -0,0 +1,10 @@
1
+ import { ApplicationConfig } from '../application/types';
2
+ import { MockedModule, Module, ModuleConfig } from '../module/types';
3
+ type TestModuleConfig = {
4
+ replaceExtensions?: boolean;
5
+ inheritTypeDefs?: Module[];
6
+ } & Partial<Pick<ApplicationConfig, 'providers' | 'modules' | 'middlewares' | 'schemaBuilder'>> & Partial<Pick<ModuleConfig, 'typeDefs' | 'resolvers'>>;
7
+ type MockModuleConfig = Partial<Pick<ModuleConfig, 'providers'>>;
8
+ export declare function mockModule(testedModule: Module, overrideConfig: MockModuleConfig): MockedModule;
9
+ export declare function testModule(testedModule: Module, config?: TestModuleConfig): import("../application/types").Application;
10
+ export {};
package/LICENSE.md DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2018 Uri Goldshtein
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.