@orion-js/graphql 4.3.1 → 4.4.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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/dist/buildSchema/getArgs/getField.d.ts +7 -0
  3. package/dist/buildSchema/getArgs/index.d.ts +3 -0
  4. package/dist/buildSchema/getMutation.d.ts +3 -0
  5. package/dist/buildSchema/getQuery.d.ts +3 -0
  6. package/dist/buildSchema/getResolvers/index.d.ts +3 -0
  7. package/dist/buildSchema/getResolvers/resolversStore.d.ts +3 -0
  8. package/dist/buildSchema/getSubscription.d.ts +3 -0
  9. package/dist/buildSchema/getSubscriptions/index.d.ts +2 -0
  10. package/dist/buildSchema/getType/BigIntScalar.d.ts +3 -0
  11. package/dist/buildSchema/getType/DateScalar.d.ts +3 -0
  12. package/dist/buildSchema/getType/JSONScalar.d.ts +3 -0
  13. package/dist/buildSchema/getType/getScalar.d.ts +1 -0
  14. package/dist/buildSchema/getType/getTypeAsResolver.d.ts +10 -0
  15. package/dist/buildSchema/getType/index.d.ts +6 -0
  16. package/dist/buildSchema/index.d.ts +3 -0
  17. package/dist/errorHandler.d.ts +1 -0
  18. package/dist/getApolloOptions/formatError.d.ts +1 -0
  19. package/dist/getApolloOptions/index.d.ts +3 -0
  20. package/dist/index.cjs +36 -36
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.ts +13 -172
  23. package/dist/index.js +35 -32
  24. package/dist/index.js.map +1 -1
  25. package/dist/pubsub.d.ts +3 -0
  26. package/dist/resolversSchemas/ResolverParamsInfo.d.ts +15 -0
  27. package/dist/resolversSchemas/getBasicResultQuery.d.ts +2 -0
  28. package/dist/resolversSchemas/getDynamicFields.d.ts +2 -0
  29. package/dist/resolversSchemas/getField.d.ts +2 -0
  30. package/dist/resolversSchemas/getModelLoadedResolvers.d.ts +3 -0
  31. package/dist/resolversSchemas/getStaticFields.d.ts +2 -0
  32. package/dist/resolversSchemas/index.d.ts +11 -0
  33. package/dist/resolversSchemas/params.d.ts +10 -0
  34. package/dist/resolversSchemas/serializeSchema.d.ts +2 -0
  35. package/dist/service/global.d.ts +15 -0
  36. package/dist/service/index.d.ts +4 -0
  37. package/dist/service/middlewares.d.ts +6 -0
  38. package/dist/service/model.d.ts +13 -0
  39. package/dist/service/subscription.d.ts +6 -0
  40. package/dist/startGraphQL.d.ts +2 -0
  41. package/dist/startGraphiQL.d.ts +3 -0
  42. package/dist/startWebsocket.d.ts +11 -0
  43. package/dist/subscription/getChannelName.d.ts +1 -0
  44. package/dist/subscription/index.d.ts +3 -0
  45. package/dist/types/index.d.ts +3 -0
  46. package/dist/types/startGraphQL.d.ts +51 -0
  47. package/dist/types/subscription.d.ts +23 -0
  48. package/dist/websockerViewer.d.ts +2 -0
  49. package/package.json +19 -20
  50. package/dist/index.d.cts +0 -172
@@ -0,0 +1,6 @@
1
+ import { OrionSubscription } from '../types/subscription';
2
+ export declare function Subscriptions(): (target: any, context: ClassDecoratorContext<any>) => void;
3
+ export declare function Subscription(): (method: any, context: ClassFieldDecoratorContext) => any;
4
+ export declare function getServiceSubscriptions(target: any): {
5
+ [key: string]: OrionSubscription;
6
+ };
@@ -0,0 +1,2 @@
1
+ import { StartGraphQLOptions } from './types/startGraphQL';
2
+ export default function (options: StartGraphQLOptions): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import { StartGraphQLOptions } from './types/startGraphQL';
2
+ import { ApolloServerOptions } from '@apollo/server';
3
+ export default function (apolloOptions: ApolloServerOptions<any>, options: StartGraphQLOptions): void;
@@ -0,0 +1,11 @@
1
+ import { StartGraphQLOptions } from './types/startGraphQL';
2
+ import { ApolloServerOptions } from '@apollo/server';
3
+ export default function (apolloOptions: ApolloServerOptions<any>, options: StartGraphQLOptions,
4
+ /**
5
+ * For testing purposes
6
+ */
7
+ wsServer?: any): {
8
+ serverWillStart(): Promise<{
9
+ drainServer(): Promise<void>;
10
+ }>;
11
+ }[];
@@ -0,0 +1 @@
1
+ export default function (name: string, params: any): string;
@@ -0,0 +1,3 @@
1
+ import { CreateOrionSubscriptionFunction } from '../types/subscription';
2
+ declare const createSubscription: CreateOrionSubscriptionFunction;
3
+ export default createSubscription;
@@ -0,0 +1,3 @@
1
+ import './subscription';
2
+ export * from './startGraphQL';
3
+ export * from './subscription';
@@ -0,0 +1,51 @@
1
+ import { GlobalResolversMap, ModelResolversMap } from '@orion-js/models';
2
+ import { express } from '@orion-js/http';
3
+ import { OrionSubscriptionsMap } from './subscription';
4
+ import { PubSubEngine } from 'graphql-subscriptions';
5
+ import { ApolloServerOptions } from '@apollo/server';
6
+ export type ExecuteGraphQLCache = (req: express.Request, res: express.Response, viewer: object, executeQuery: () => Promise<string>) => Promise<string>;
7
+ export interface ModelsResolversMap {
8
+ [key: string]: ModelResolversMap;
9
+ }
10
+ type SchemaOmits = 'schema' | 'schemaHash' | 'context' | 'useGraphiql';
11
+ export interface StartGraphQLOptions extends Omit<ApolloServerOptions<any>, SchemaOmits> {
12
+ /**
13
+ * A map with all the global resolvers
14
+ */
15
+ resolvers: GlobalResolversMap;
16
+ /**
17
+ * A map with all the model resolvers. You must only add the models that you want to extend with resolvers.
18
+ */
19
+ modelResolvers?: ModelsResolversMap;
20
+ /**
21
+ * A Map with all global subscriptions
22
+ */
23
+ subscriptions?: OrionSubscriptionsMap;
24
+ /**
25
+ * A function that executes the http level cache of graphql queries
26
+ */
27
+ /**
28
+ * Should use GraphiQL. Default to true
29
+ */
30
+ useGraphiql?: boolean;
31
+ /**
32
+ * Pass another express app
33
+ */
34
+ app?: express.Application;
35
+ /**
36
+ * The pubsub provider to use. Default to the single server pubsub.
37
+ * If you are using multiple servers you must pass a pubsub provider like RedisPubSub
38
+ */
39
+ pubsub?: PubSubEngine;
40
+ /**
41
+ * Path to the graphql endpoint. Default to /graphql
42
+ */
43
+ path?: string;
44
+ /**
45
+ * Body parser options for the graphql endpoint.
46
+ */
47
+ bodyParserOptions?: {
48
+ limit?: number | string | undefined;
49
+ };
50
+ }
51
+ export {};
@@ -0,0 +1,23 @@
1
+ import { ResolverOptions } from '@orion-js/resolvers';
2
+ import { InferSchemaType, SchemaFieldType } from '@orion-js/schema';
3
+ export declare class OrionSubscription<TParamsSchema extends SchemaFieldType = SchemaFieldType, TReturnsSchema extends SchemaFieldType = SchemaFieldType> {
4
+ name: string;
5
+ params: TParamsSchema;
6
+ subscribe: (callParams: InferSchemaType<TParamsSchema>, viewer: InferSchemaType<TReturnsSchema>) => {};
7
+ returns: TReturnsSchema;
8
+ publish: (params: InferSchemaType<TParamsSchema>, data: InferSchemaType<TReturnsSchema>) => Promise<void>;
9
+ }
10
+ export type CreateOrionSubscriptionFunction = <TParamsSchema extends SchemaFieldType = SchemaFieldType, TReturnsSchema extends SchemaFieldType = SchemaFieldType, TViewer = any>(options: OrionSubscriptionOptions<TParamsSchema, TReturnsSchema, TViewer>) => OrionSubscription<TParamsSchema, TReturnsSchema>;
11
+ export interface OrionSubscriptionsMap {
12
+ [key: string]: OrionSubscription;
13
+ }
14
+ export type OrionSubscriptionOptions<TParamsSchema extends SchemaFieldType = SchemaFieldType, TReturnsSchema extends SchemaFieldType = SchemaFieldType, TViewer = any> = Omit<ResolverOptions<TParamsSchema, TReturnsSchema, TViewer>, 'resolve'> & {
15
+ /**
16
+ * This function is used to check if the user can subscribe to the subscription.
17
+ * If not provided, the subscription will be public.
18
+ * @param params - The parameters of the subscription.
19
+ * @param viewer - The viewer of the subscription.
20
+ * @returns true if the user can subscribe to the subscription, false otherwise.
21
+ */
22
+ canSubscribe?: (params: InferSchemaType<TParamsSchema>, viewer: TViewer) => Promise<boolean>;
23
+ };
@@ -0,0 +1,2 @@
1
+ export declare const getWebsockerViewer: (connectionParams: any) => Promise<any>;
2
+ export declare const setGetWebsockerViewer: (getViewerFunc: (connectionParams: any) => any) => void;
package/package.json CHANGED
@@ -1,27 +1,20 @@
1
1
  {
2
2
  "name": "@orion-js/graphql",
3
- "version": "4.3.1",
3
+ "version": "4.4.0",
4
4
  "main": "./dist/index.cjs",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
7
- "scripts": {
8
- "test": "bun test",
9
- "prepare": "bun run build",
10
- "clean": "rm -rf ./dist",
11
- "build": "tsup",
12
- "dev": "tsup --watch"
13
- },
14
7
  "dependencies": {
15
8
  "@apollo/server": "^4.3.0",
16
9
  "@graphql-tools/schema": "^9.0.12",
17
- "@orion-js/env": "4.3.0",
18
- "@orion-js/helpers": "4.3.0",
19
- "@orion-js/http": "4.3.1",
20
- "@orion-js/models": "4.3.0",
21
- "@orion-js/resolvers": "4.3.0",
22
- "@orion-js/schema": "4.3.0",
23
- "@orion-js/services": "4.3.0",
24
- "@orion-js/typed-model": "4.3.0",
10
+ "@orion-js/env": "4.4.0",
11
+ "@orion-js/helpers": "4.4.0",
12
+ "@orion-js/http": "4.4.0",
13
+ "@orion-js/models": "4.4.0",
14
+ "@orion-js/resolvers": "4.4.0",
15
+ "@orion-js/schema": "4.4.0",
16
+ "@orion-js/services": "4.4.0",
17
+ "@orion-js/typed-model": "4.4.0",
25
18
  "graphql-scalars": "^1.24.1",
26
19
  "graphql-subscriptions": "2.0.0",
27
20
  "graphql-tag": "^2.12.6",
@@ -38,10 +31,10 @@
38
31
  "supertest": "^6.3.3",
39
32
  "superwstest": "^2.0.3",
40
33
  "tsup": "^8.0.1",
41
- "typescript": "^5.4.5"
34
+ "typescript": "^7.0.2"
42
35
  },
43
36
  "peerDependencies": {
44
- "@orion-js/logger": "4.3.0",
37
+ "@orion-js/logger": "4.4.0",
45
38
  "graphql": "*"
46
39
  },
47
40
  "publishConfig": {
@@ -58,5 +51,11 @@
58
51
  },
59
52
  "files": [
60
53
  "dist"
61
- ]
62
- }
54
+ ],
55
+ "scripts": {
56
+ "test": "bun test",
57
+ "clean": "rm -rf ./dist",
58
+ "build": "tsup && bun run ../../scripts/emit-declarations.ts",
59
+ "dev": "tsup --watch"
60
+ }
61
+ }
package/dist/index.d.cts DELETED
@@ -1,172 +0,0 @@
1
- import * as _orion_js_resolvers from '@orion-js/resolvers';
2
- import { ResolverOptions, GlobalResolverOptions, GlobalResolver, ModelResolver as ModelResolver$1, ResolverMiddleware } from '@orion-js/resolvers';
3
- export { createResolver } from '@orion-js/resolvers';
4
- import * as _orion_js_schema from '@orion-js/schema';
5
- import { SchemaFieldType, InferSchemaType, Schema, SchemaWithMetadata, SchemaNode, SchemaInAnyOrionForm } from '@orion-js/schema';
6
- import { ModelResolversMap, GlobalResolversMap } from '@orion-js/models';
7
- import { express } from '@orion-js/http';
8
- import { PubSubEngine } from 'graphql-subscriptions';
9
- import { ApolloServerOptions } from '@apollo/server';
10
- import * as graphql from 'graphql';
11
- export { graphql as GraphQL };
12
-
13
- declare class OrionSubscription<TParamsSchema extends SchemaFieldType = SchemaFieldType, TReturnsSchema extends SchemaFieldType = SchemaFieldType> {
14
- name: string;
15
- params: TParamsSchema;
16
- subscribe: (callParams: InferSchemaType<TParamsSchema>, viewer: InferSchemaType<TReturnsSchema>) => {};
17
- returns: TReturnsSchema;
18
- publish: (params: InferSchemaType<TParamsSchema>, data: InferSchemaType<TReturnsSchema>) => Promise<void>;
19
- }
20
- type CreateOrionSubscriptionFunction = <TParamsSchema extends SchemaFieldType = SchemaFieldType, TReturnsSchema extends SchemaFieldType = SchemaFieldType, TViewer = any>(options: OrionSubscriptionOptions<TParamsSchema, TReturnsSchema, TViewer>) => OrionSubscription<TParamsSchema, TReturnsSchema>;
21
- interface OrionSubscriptionsMap {
22
- [key: string]: OrionSubscription;
23
- }
24
- type OrionSubscriptionOptions<TParamsSchema extends SchemaFieldType = SchemaFieldType, TReturnsSchema extends SchemaFieldType = SchemaFieldType, TViewer = any> = Omit<ResolverOptions<TParamsSchema, TReturnsSchema, TViewer>, 'resolve'> & {
25
- /**
26
- * This function is used to check if the user can subscribe to the subscription.
27
- * If not provided, the subscription will be public.
28
- * @param params - The parameters of the subscription.
29
- * @param viewer - The viewer of the subscription.
30
- * @returns true if the user can subscribe to the subscription, false otherwise.
31
- */
32
- canSubscribe?: (params: InferSchemaType<TParamsSchema>, viewer: TViewer) => Promise<boolean>;
33
- };
34
-
35
- type ExecuteGraphQLCache = (req: express.Request, res: express.Response, viewer: object, executeQuery: () => Promise<string>) => Promise<string>;
36
- interface ModelsResolversMap {
37
- [key: string]: ModelResolversMap;
38
- }
39
- type SchemaOmits = 'schema' | 'schemaHash' | 'context' | 'useGraphiql';
40
- interface StartGraphQLOptions extends Omit<ApolloServerOptions<any>, SchemaOmits> {
41
- /**
42
- * A map with all the global resolvers
43
- */
44
- resolvers: GlobalResolversMap;
45
- /**
46
- * A map with all the model resolvers. You must only add the models that you want to extend with resolvers.
47
- */
48
- modelResolvers?: ModelsResolversMap;
49
- /**
50
- * A Map with all global subscriptions
51
- */
52
- subscriptions?: OrionSubscriptionsMap;
53
- /**
54
- * A function that executes the http level cache of graphql queries
55
- */
56
- /**
57
- * Should use GraphiQL. Default to true
58
- */
59
- useGraphiql?: boolean;
60
- /**
61
- * Pass another express app
62
- */
63
- app?: express.Application;
64
- /**
65
- * The pubsub provider to use. Default to the single server pubsub.
66
- * If you are using multiple servers you must pass a pubsub provider like RedisPubSub
67
- */
68
- pubsub?: PubSubEngine;
69
- /**
70
- * Path to the graphql endpoint. Default to /graphql
71
- */
72
- path?: string;
73
- /**
74
- * Body parser options for the graphql endpoint.
75
- */
76
- bodyParserOptions?: {
77
- limit?: number | string | undefined;
78
- };
79
- }
80
-
81
- declare const createSubscription$1: CreateOrionSubscriptionFunction;
82
-
83
- declare function export_default$1(options: StartGraphQLOptions): Promise<void>;
84
-
85
- declare function export_default(apolloOptions: ApolloServerOptions<any>, options: StartGraphQLOptions): void;
86
-
87
- declare const _default$1: {
88
- params: _orion_js_resolvers.GlobalResolver<{
89
- name: {
90
- type: "ID";
91
- };
92
- mutation: {
93
- type: BooleanConstructor;
94
- };
95
- }, {
96
- name: {
97
- type: "string";
98
- };
99
- params: {
100
- type: "blackbox";
101
- };
102
- result: {
103
- type: "string";
104
- };
105
- basicResultQuery: {
106
- type: "string";
107
- };
108
- }, any, any>;
109
- };
110
-
111
- declare const _default: {
112
- name: {
113
- type: "string";
114
- };
115
- params: {
116
- type: "blackbox";
117
- };
118
- result: {
119
- type: "string";
120
- };
121
- basicResultQuery: {
122
- type: "string";
123
- };
124
- };
125
-
126
- declare function serializeSchema(params: Schema): Promise<SchemaWithMetadata>;
127
-
128
- declare function getBasicQuery(field: SchemaNode): Promise<string>;
129
-
130
- declare const createQuery: <TParams extends SchemaFieldType = any, TReturns extends SchemaFieldType = any, TViewer = any, TInfo = any>(options: GlobalResolverOptions<TParams, TReturns, TViewer, TInfo>) => GlobalResolver<TParams, TReturns, TViewer, TInfo>;
131
- declare const createMutation: <TParams extends SchemaFieldType = any, TReturns extends SchemaFieldType = any, TViewer = any, TInfo = any>(options: Omit<GlobalResolverOptions<TParams, TReturns, TViewer, TInfo>, "mutation">) => GlobalResolver<TParams, TReturns, TViewer, TInfo>;
132
- declare const internalResolversMetadata: WeakMap<any, Record<string, any>>;
133
- declare function Resolvers(): (target: any, context: ClassDecoratorContext<any>) => void;
134
- declare function Query(): (method: any, context: ClassFieldDecoratorContext | ClassMethodDecoratorContext) => any;
135
- declare function Query(options?: Omit<ResolverOptions<any>, 'resolve' | 'mutation'>): (method: any, context: ClassMethodDecoratorContext) => any;
136
- declare function Mutation(): (method: any, context: ClassFieldDecoratorContext | ClassMethodDecoratorContext) => any;
137
- declare function Mutation(options?: Omit<ResolverOptions<any>, 'resolve' | 'mutation'>): (method: any, context: ClassMethodDecoratorContext) => any;
138
- declare function registerPendingResolver(propertyKey: string, setup: (instance: any) => any): void;
139
- declare function getServiceResolvers(target: any): {
140
- [key: string]: GlobalResolver<any, any, any, any>;
141
- };
142
-
143
- declare const createModelResolver: <TItem = any, TParams extends _orion_js_schema.SchemaFieldType = any, TReturns extends _orion_js_schema.SchemaFieldType = any, TViewer = any, TInfo = any>(options: _orion_js_resolvers.ModelResolverOptions<TItem, TParams, TReturns, TViewer, TInfo>) => ModelResolver$1<TItem, TParams, TReturns, TViewer, TInfo>;
144
- interface ModelResolversOptions {
145
- modelName?: string;
146
- }
147
- declare function ModelResolvers(typedSchema: any, options?: ModelResolversOptions): (target: any, context: ClassDecoratorContext<any>) => void;
148
- declare function ModelResolver(): (method: any, context: ClassFieldDecoratorContext | ClassMethodDecoratorContext) => any;
149
- declare function ModelResolver(options?: Omit<ResolverOptions<any>, 'resolve' | 'middlewares'>): (method: any, context: ClassMethodDecoratorContext) => any;
150
- declare function getServiceModelResolvers(target: any): {
151
- [key: string]: {
152
- [key: string]: ModelResolver$1;
153
- };
154
- };
155
-
156
- declare function Subscriptions(): (target: any, context: ClassDecoratorContext<any>) => void;
157
- declare function Subscription(): (method: any, context: ClassFieldDecoratorContext) => any;
158
- declare function getServiceSubscriptions(target: any): {
159
- [key: string]: OrionSubscription;
160
- };
161
-
162
- declare function getTargetMetadata(target: any, propertyKey: string, metadataKey: string): any;
163
- declare function UseMiddleware<TMiddleware extends ResolverMiddleware, This>(params: TMiddleware): (method: any, context: ClassMethodDecoratorContext<This, typeof method>) => any;
164
- declare function ResolverParams<TParams extends SchemaInAnyOrionForm, This>(params: TParams): (method: any, context: ClassMethodDecoratorContext<This, typeof method>) => any;
165
- declare function ResolverReturns<This>(returns: any): (method: any, context: ClassMethodDecoratorContext<This, typeof method>) => any;
166
-
167
- declare const getWebsockerViewer: (connectionParams: any) => Promise<any>;
168
- declare const setGetWebsockerViewer: (getViewerFunc: (connectionParams: any) => any) => void;
169
-
170
- declare const createSubscription: CreateOrionSubscriptionFunction;
171
-
172
- export { type CreateOrionSubscriptionFunction, type ExecuteGraphQLCache, ModelResolver, ModelResolvers, type ModelResolversOptions, type ModelsResolversMap, Mutation, OrionSubscription, type OrionSubscriptionOptions, type OrionSubscriptionsMap, Query, ResolverParams, _default as ResolverParamsInfo, ResolverReturns, Resolvers, type StartGraphQLOptions, Subscription, Subscriptions, UseMiddleware, createModelResolver, createMutation, createQuery, createSubscription, getBasicQuery as getBasicResultQuery, getServiceModelResolvers, getServiceResolvers, getServiceSubscriptions, getTargetMetadata, getWebsockerViewer, internalResolversMetadata, registerPendingResolver, _default$1 as resolversSchemas, serializeSchema, setGetWebsockerViewer, export_default$1 as startGraphQL, export_default as startGraphiQL, createSubscription$1 as subscription };