@rxdi/graphql 0.7.181 → 0.7.183

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.
@@ -1,2 +1,19 @@
1
- import { GraphQLInputFieldConfigMap } from "graphql";
2
- export declare function Mutation(input?: GraphQLInputFieldConfigMap, meta?: Pick<GraphQLInputFieldConfigMap, 'description'>): (t: any, propKey: string, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
1
+ import { GraphQLInputFieldConfigMap } from 'graphql';
2
+ /**
3
+ * @Mutation annotation is creating GraphQLInputObjectType dynamically
4
+ * @param fields parameter is type GraphQLInputFieldConfigMap
5
+ * @param meta parameter has "description" field which is then added to the new GraphQLInputObjectType
6
+ *
7
+ * "input" param is actually "fields" param inside the dynamically generated GraphQLInputObjectType
8
+ *
9
+ * ```typescript
10
+ * new GraphQLInputObjectType({
11
+ * name: 'Taken from the descriptor name automatically',
12
+ * description: 'Taken from "meta.description" field'
13
+ * fields: input,
14
+ * })
15
+ * ```
16
+ */
17
+ export declare function Mutation(fields?: GraphQLInputFieldConfigMap, meta?: {
18
+ description?: string;
19
+ }): (t: any, propKey: string, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
@@ -1,7 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Mutation = void 0;
4
- function Mutation(input, meta) {
4
+ /**
5
+ * @Mutation annotation is creating GraphQLInputObjectType dynamically
6
+ * @param fields parameter is type GraphQLInputFieldConfigMap
7
+ * @param meta parameter has "description" field which is then added to the new GraphQLInputObjectType
8
+ *
9
+ * "input" param is actually "fields" param inside the dynamically generated GraphQLInputObjectType
10
+ *
11
+ * ```typescript
12
+ * new GraphQLInputObjectType({
13
+ * name: 'Taken from the descriptor name automatically',
14
+ * description: 'Taken from "meta.description" field'
15
+ * fields: input,
16
+ * })
17
+ * ```
18
+ */
19
+ function Mutation(fields, meta) {
5
20
  return (t, propKey, descriptor) => {
6
21
  const originalMethod = descriptor.value;
7
22
  const target = t;
@@ -9,15 +24,14 @@ function Mutation(input, meta) {
9
24
  descriptor.value = function (...args) {
10
25
  const returnValue = Object.create({});
11
26
  returnValue.resolve = originalMethod;
12
- returnValue.args = input ? input : null;
27
+ returnValue.args = fields ? fields : null;
13
28
  returnValue.method_type = 'mutation';
14
29
  returnValue.method_name = propertyKey;
15
30
  returnValue.description = meta ? meta.description : null;
16
31
  returnValue.target = target;
17
32
  return returnValue;
18
33
  };
19
- target.constructor._descriptors =
20
- target.constructor._descriptors || new Map();
34
+ target.constructor._descriptors = target.constructor._descriptors || new Map();
21
35
  target.constructor._descriptors.set(propertyKey, descriptor);
22
36
  return descriptor;
23
37
  };
@@ -20,4 +20,21 @@ export declare class GenericGapiResolversType implements GraphQLControllerOption
20
20
  };
21
21
  };
22
22
  }
23
- export declare function Query<T>(options?: GraphQLInputFieldConfigMap, meta?: Pick<GraphQLInputFieldConfigMap, 'description'>): (t: any, propKey: any, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
23
+ /**
24
+ * @Query annotation is creating GraphQLInputObjectType dynamically
25
+ * @param fields parameter is type GraphQLInputFieldConfigMap
26
+ * @param meta parameter has "description" field which is then added to the new GraphQLInputObjectType
27
+ *
28
+ * "input" param is actually "fields" param inside the dynamically generated GraphQLInputObjectType
29
+ *
30
+ * ```typescript
31
+ * new GraphQLInputObjectType({
32
+ * name: 'Taken from the descriptor name automatically',
33
+ * description: 'Taken from "meta.description" field'
34
+ * fields: input,
35
+ * })
36
+ * ```
37
+ */
38
+ export declare function Query<T>(fields?: GraphQLInputFieldConfigMap, meta?: {
39
+ description?: string;
40
+ }): (t: any, propKey: any, descriptor: TypedPropertyDescriptor<any>) => TypedPropertyDescriptor<any>;
@@ -4,7 +4,22 @@ exports.Query = exports.GenericGapiResolversType = void 0;
4
4
  class GenericGapiResolversType {
5
5
  }
6
6
  exports.GenericGapiResolversType = GenericGapiResolversType;
7
- function Query(options, meta) {
7
+ /**
8
+ * @Query annotation is creating GraphQLInputObjectType dynamically
9
+ * @param fields parameter is type GraphQLInputFieldConfigMap
10
+ * @param meta parameter has "description" field which is then added to the new GraphQLInputObjectType
11
+ *
12
+ * "input" param is actually "fields" param inside the dynamically generated GraphQLInputObjectType
13
+ *
14
+ * ```typescript
15
+ * new GraphQLInputObjectType({
16
+ * name: 'Taken from the descriptor name automatically',
17
+ * description: 'Taken from "meta.description" field'
18
+ * fields: input,
19
+ * })
20
+ * ```
21
+ */
22
+ function Query(fields, meta) {
8
23
  return (t, propKey, descriptor) => {
9
24
  const originalMethod = descriptor.value;
10
25
  const target = t;
@@ -12,7 +27,7 @@ function Query(options, meta) {
12
27
  descriptor.value = function (...args) {
13
28
  const returnValue = Object.create({});
14
29
  returnValue.resolve = originalMethod;
15
- returnValue.args = options ? options : null;
30
+ returnValue.args = fields ? fields : null;
16
31
  returnValue.method_type = 'query';
17
32
  returnValue.method_name = propertyKey;
18
33
  returnValue.description = meta ? meta.description : null;
@@ -23,7 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.ApolloService = void 0;
25
25
  const core_1 = require("@rxdi/core");
26
- const Boom = require("@hapi/boom");
26
+ const boom_1 = require("@hapi/boom");
27
27
  const hapi_1 = require("@hapi/hapi");
28
28
  const apollo_server_core_1 = require("apollo-server-core");
29
29
  const hapi_2 = require("@rxdi/hapi");
@@ -43,19 +43,18 @@ let ApolloService = class ApolloService {
43
43
  }
44
44
  catch (e) { }
45
45
  if (onRequest) {
46
- return yield onRequest(context => this.makeGQLRequest(request, response, error, context), request, response, error);
46
+ return yield onRequest((context) => this.makeGQLRequest(request, response, error, context), request, response, error);
47
47
  }
48
- this.config.graphqlOptions.context =
49
- this.config.graphqlOptions.context || {};
48
+ this.config.graphqlOptions.context = this.config.graphqlOptions.context || {};
50
49
  if (request.headers.authorization &&
51
50
  request.headers.authorization !== 'undefined' &&
52
51
  this.config.authentication) {
53
52
  try {
54
- const serviceUtilsService = core_1.Container.get((this.config.authentication));
53
+ const serviceUtilsService = core_1.Container.get(this.config.authentication);
55
54
  this.config.graphqlOptions.context['user'] = yield serviceUtilsService.validateToken(request.headers.authorization);
56
55
  }
57
56
  catch (e) {
58
- return Boom.unauthorized();
57
+ return (0, boom_1.unauthorized)();
59
58
  }
60
59
  }
61
60
  else {
@@ -75,7 +74,7 @@ let ApolloService = class ApolloService {
75
74
  console.error(error);
76
75
  }
77
76
  if ('HttpQueryError' !== error.name) {
78
- throw Boom.boomify(error);
77
+ throw (0, boom_1.boomify)(error);
79
78
  }
80
79
  if (error &&
81
80
  error.message.constructor === String &&
@@ -89,9 +88,9 @@ let ApolloService = class ApolloService {
89
88
  response.type('application/json');
90
89
  return response;
91
90
  }
92
- const err = new Boom(error.message, { statusCode: error.statusCode });
91
+ const err = new boom_1.Boom(error.message, { statusCode: error.statusCode });
93
92
  if (error.headers) {
94
- Object.keys(error.headers).forEach(header => (err.output.headers[header] = error.headers[header]));
93
+ Object.keys(error.headers).forEach((header) => (err.output.headers[header] = error.headers[header]));
95
94
  }
96
95
  // Boom hides the error when status code is 500
97
96
  err.output.payload.message = error.message;
@@ -133,14 +132,14 @@ let ApolloService = class ApolloService {
133
132
  this.hookService.AttachHooks([
134
133
  this.config.graphqlOptions.schema.getQueryType(),
135
134
  this.config.graphqlOptions.schema.getMutationType(),
136
- this.config.graphqlOptions.schema.getSubscriptionType()
135
+ this.config.graphqlOptions.schema.getSubscriptionType(),
137
136
  ]);
138
137
  this.server.route({
139
138
  method: ['GET', 'POST'],
140
139
  path: this.config.path || '/graphql',
141
140
  vhost: this.config.vhost,
142
141
  config: this.config.route || {},
143
- handler: this.handler
142
+ handler: this.handler,
144
143
  });
145
144
  });
146
145
  }
@@ -160,7 +159,7 @@ let ApolloService = class ApolloService {
160
159
  ? // TODO type payload as string or Record
161
160
  request.payload
162
161
  : request.query,
163
- request: (0, apollo_server_core_1.convertNodeHttpToRequest)(request.raw.req)
162
+ request: (0, apollo_server_core_1.convertNodeHttpToRequest)(request.raw.req),
164
163
  });
165
164
  const response = h.response(graphqlResponse);
166
165
  response.type('application/json');
@@ -1,6 +1,5 @@
1
1
  import { GRAPHQL_PLUGIN_CONFIG } from '../../config.tokens';
2
2
  import { HapiConfigModel } from '@rxdi/hapi';
3
- import { ConfigModel } from '@rxdi/core';
4
3
  import { SendRequestQueryType } from '../../plugin-init';
5
4
  import { Server } from '@hapi/hapi';
6
5
  export interface CoreModuleConfig {
@@ -73,7 +72,7 @@ export declare const setConfigGraphql: (config?: GRAPHQL_PLUGIN_CONFIG) => {
73
72
  };
74
73
  graphiqlPlaygroundConfig?: import("graphql-playground-html").RenderPageOptions;
75
74
  };
76
- export declare const startServer: (config?: CoreModuleConfig, bootstrapOptions?: ConfigModel) => import("rxjs").Observable<import("@rxdi/core/dist/container/observable-interface").ObservableContainer>;
75
+ export declare const startServer: any;
77
76
  export declare const stopServer: () => never;
78
77
  export declare const getServer: () => import("rxjs").Observable<Server<import("@hapi/hapi").ServerApplicationState>>;
79
78
  export declare const getGraphqlSchema: () => import("rxjs").Observable<import("graphql").GraphQLSchema>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/graphql",
3
- "version": "0.7.181",
3
+ "version": "0.7.183",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rxdi/graphql"
@@ -40,8 +40,8 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "graphql": "^14.5.8",
43
- "@rxdi/core": "^0.7.180",
44
- "@rxdi/hapi": "^0.7.180",
43
+ "@rxdi/core": "^0.7.182",
44
+ "@rxdi/hapi": "^0.7.182",
45
45
  "@types/graphql": "^14.5.0",
46
46
  "@types/jest": "^24.0.22",
47
47
  "@types/node": "^12.0.10",