@rxdi/graphql 0.7.180 → 0.7.182

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 +1,19 @@
1
- export declare function Mutation(options?: any): (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(options) {
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,14 +24,14 @@ function Mutation(options) {
9
24
  descriptor.value = function (...args) {
10
25
  const returnValue = Object.create({});
11
26
  returnValue.resolve = originalMethod;
12
- returnValue.args = options ? options : null;
27
+ returnValue.args = fields ? fields : null;
13
28
  returnValue.method_type = 'mutation';
14
29
  returnValue.method_name = propertyKey;
30
+ returnValue.description = meta ? meta.description : null;
15
31
  returnValue.target = target;
16
32
  return returnValue;
17
33
  };
18
- target.constructor._descriptors =
19
- target.constructor._descriptors || new Map();
34
+ target.constructor._descriptors = target.constructor._descriptors || new Map();
20
35
  target.constructor._descriptors.set(propertyKey, descriptor);
21
36
  return descriptor;
22
37
  };
@@ -1,4 +1,4 @@
1
- import { GraphQLObjectType, GraphQLNonNull } from 'graphql';
1
+ import { GraphQLObjectType, GraphQLNonNull, GraphQLInputFieldConfigMap } from 'graphql';
2
2
  import { GraphQLControllerOptions } from '../../decorators/guard/guard.interface';
3
3
  export declare class GenericGapiResolversType implements GraphQLControllerOptions {
4
4
  scope?: string[];
@@ -9,6 +9,7 @@ export declare class GenericGapiResolversType implements GraphQLControllerOption
9
9
  interceptor?: Function;
10
10
  interceptors?: any[];
11
11
  method_name?: string;
12
+ description?: string;
12
13
  subscribe?: (root: any, params: any, context: any, info: any, ...args: any[]) => {};
13
14
  method_type?: 'query' | 'subscription' | 'mutation' | 'event';
14
15
  type: GraphQLObjectType;
@@ -19,4 +20,21 @@ export declare class GenericGapiResolversType implements GraphQLControllerOption
19
20
  };
20
21
  };
21
22
  }
22
- export declare function Query<T>(options?: any): (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) {
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,9 +27,10 @@ function Query(options) {
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;
33
+ returnValue.description = meta ? meta.description : null;
18
34
  returnValue.target = target;
19
35
  return returnValue;
20
36
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rxdi/graphql",
3
- "version": "0.7.180",
3
+ "version": "0.7.182",
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.179",
44
- "@rxdi/hapi": "^0.7.179",
43
+ "@rxdi/core": "^0.7.181",
44
+ "@rxdi/hapi": "^0.7.181",
45
45
  "@types/graphql": "^14.5.0",
46
46
  "@types/jest": "^24.0.22",
47
47
  "@types/node": "^12.0.10",