@kiwano/core 0.0.1 → 0.0.6
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/Builder.js +2 -2
- package/argument.d.ts +4 -0
- package/argument.js +28 -11
- package/enumType.js +7 -10
- package/enumValue.js +5 -7
- package/field.d.ts +4 -0
- package/field.js +33 -13
- package/inputField.d.ts +4 -0
- package/inputField.js +28 -11
- package/inputObjectType.js +7 -10
- package/objectType.js +7 -10
- package/package.json +8 -5
- package/plugin/MultiPlugin.d.ts +16 -16
- package/plugin/MultiPlugin.js +32 -32
- package/plugin/acl/{Acl.d.ts → acl.d.ts} +16 -8
- package/plugin/acl/{Acl.js → acl.js} +49 -25
- package/plugin/acl/index.d.ts +1 -4
- package/plugin/acl/index.js +1 -7
- package/plugin/acl/middleware.d.ts +3 -3
- package/plugin/acl/middleware.js +10 -13
- package/plugin/common.d.ts +16 -16
- package/plugin/filter/equals.d.ts +2 -2
- package/plugin/filter/equals.js +3 -4
- package/plugin/filter/search.d.ts +2 -2
- package/plugin/filter/search.js +3 -7
- package/plugin/pagination/connection.d.ts +2 -2
- package/plugin/pagination/connection.js +1 -2
- package/plugin/pagination/firstAfter.d.ts +2 -2
- package/plugin/pagination/firstAfter.js +1 -2
- package/plugin/pagination/items.d.ts +2 -2
- package/plugin/pagination/items.js +1 -2
- package/plugin/pagination/offsetLimit.d.ts +2 -2
- package/plugin/pagination/offsetLimit.js +1 -2
- package/plugin/sort/sort.d.ts +2 -2
- package/plugin/sort/sort.js +3 -4
- package/schema.js +22 -25
- package/unionType.js +6 -9
- package/util.d.ts +7 -0
- package/util.js +22 -11
- package/plugin/acl/plugin.d.ts +0 -15
- package/plugin/acl/plugin.js +0 -50
package/Builder.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.resolveName = exports.FinalizeContext = exports.BuildContext = exports.builderInfoExtensionName = exports.BuilderError = void 0;
|
|
7
|
-
const
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
8
|
const graphql_1 = require("graphql");
|
|
9
9
|
const FrameworkError_1 = __importDefault(require("./error/FrameworkError"));
|
|
10
10
|
class BuilderError extends FrameworkError_1.default {
|
|
@@ -109,6 +109,6 @@ class FinalizeContext {
|
|
|
109
109
|
}
|
|
110
110
|
exports.FinalizeContext = FinalizeContext;
|
|
111
111
|
function resolveName(name) {
|
|
112
|
-
return
|
|
112
|
+
return lodash_1.isFunction(name) ? name() : name;
|
|
113
113
|
}
|
|
114
114
|
exports.resolveName = resolveName;
|
package/argument.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface ArgumentBuilderInfo {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
extensions: Map<string, any>;
|
|
10
10
|
nonNull: boolean;
|
|
11
|
+
nonNullList: boolean;
|
|
11
12
|
list: boolean;
|
|
12
13
|
plugins: Plugin[];
|
|
13
14
|
}
|
|
@@ -16,6 +17,7 @@ export declare class ArgumentBuilder extends Builder<GraphQLArgumentConfig> {
|
|
|
16
17
|
protected _description?: string;
|
|
17
18
|
protected _extensions: Map<string, any>;
|
|
18
19
|
protected _nonNull: boolean;
|
|
20
|
+
protected _nonNullList: boolean;
|
|
19
21
|
protected _list: boolean;
|
|
20
22
|
constructor(name: BuilderName, type: ArgumentType);
|
|
21
23
|
type(type: ArgumentType): this;
|
|
@@ -25,6 +27,8 @@ export declare class ArgumentBuilder extends Builder<GraphQLArgumentConfig> {
|
|
|
25
27
|
nonNull(nonNull: boolean): this;
|
|
26
28
|
list(): this;
|
|
27
29
|
list(list: boolean): this;
|
|
30
|
+
nonNullList(): this;
|
|
31
|
+
nonNullList(nonNullList: boolean): this;
|
|
28
32
|
finalizeBuilder(context: FinalizeContext): Promise<void>;
|
|
29
33
|
finalizeArgument(context: FinalizeContext, info: ArgumentBuilderInfo): Promise<void>;
|
|
30
34
|
build(context: BuildContext): GraphQLArgumentConfig;
|
package/argument.js
CHANGED
|
@@ -18,25 +18,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.argument = exports.ArgumentBuilder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const clone_1 = __importDefault(require("lodash/clone"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
28
24
|
const graphql_1 = require("graphql");
|
|
29
25
|
const Builder_1 = __importStar(require("./Builder"));
|
|
26
|
+
const util_1 = require("./util");
|
|
30
27
|
class ArgumentBuilder extends Builder_1.default {
|
|
31
28
|
constructor(name, type) {
|
|
32
29
|
super(name);
|
|
33
30
|
this._extensions = new Map();
|
|
34
31
|
this._nonNull = false;
|
|
32
|
+
this._nonNullList = false;
|
|
35
33
|
this._list = false;
|
|
36
|
-
this.
|
|
34
|
+
this.type(type);
|
|
37
35
|
}
|
|
38
36
|
type(type) {
|
|
39
|
-
|
|
37
|
+
const resolvedType = util_1.resolveType(type);
|
|
38
|
+
this._type = resolvedType.type;
|
|
39
|
+
if (resolvedType.nonNull)
|
|
40
|
+
this.nonNull();
|
|
41
|
+
if (resolvedType.list)
|
|
42
|
+
this.list();
|
|
43
|
+
if (resolvedType.nonNullList)
|
|
44
|
+
this.nonNullList();
|
|
40
45
|
return this;
|
|
41
46
|
}
|
|
42
47
|
description(description) {
|
|
@@ -55,6 +60,13 @@ class ArgumentBuilder extends Builder_1.default {
|
|
|
55
60
|
this._list = list;
|
|
56
61
|
return this;
|
|
57
62
|
}
|
|
63
|
+
nonNullList(nonNullList = true) {
|
|
64
|
+
if (nonNullList) {
|
|
65
|
+
this.list();
|
|
66
|
+
}
|
|
67
|
+
this._nonNullList = nonNullList;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
58
70
|
async finalizeBuilder(context) {
|
|
59
71
|
const info = this.info();
|
|
60
72
|
await this._executePlugins('beforeFinalizeArgument', plugin => plugin.beforeFinalizeArgument(this, context, info));
|
|
@@ -63,9 +75,13 @@ class ArgumentBuilder extends Builder_1.default {
|
|
|
63
75
|
}
|
|
64
76
|
async finalizeArgument(context, info) { }
|
|
65
77
|
build(context) {
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
const info = this.info();
|
|
79
|
+
this._executePluginsSync('beforeBuildArgument', plugin => plugin.beforeBuildArgument(this, context, info));
|
|
80
|
+
let type = lodash_1.isString(this._type) ? context.getType(this._type) : this._type;
|
|
68
81
|
if (this._list) {
|
|
82
|
+
if (this._nonNullList) {
|
|
83
|
+
type = graphql_1.GraphQLNonNull(type);
|
|
84
|
+
}
|
|
69
85
|
type = graphql_1.GraphQLList(type);
|
|
70
86
|
}
|
|
71
87
|
if (this._nonNull) {
|
|
@@ -76,7 +92,7 @@ class ArgumentBuilder extends Builder_1.default {
|
|
|
76
92
|
description: this._description,
|
|
77
93
|
extensions: Object.assign({ [Builder_1.builderInfoExtensionName]: this.info() }, Object.fromEntries(this._extensions))
|
|
78
94
|
};
|
|
79
|
-
this._executePluginsSync('afterBuildArgument', plugin => plugin.afterBuildArgument(this, context, argument));
|
|
95
|
+
this._executePluginsSync('afterBuildArgument', plugin => plugin.afterBuildArgument(this, context, info, argument));
|
|
80
96
|
return argument;
|
|
81
97
|
}
|
|
82
98
|
info() {
|
|
@@ -86,8 +102,9 @@ class ArgumentBuilder extends Builder_1.default {
|
|
|
86
102
|
description: this._description,
|
|
87
103
|
extensions: new Map(this._extensions),
|
|
88
104
|
nonNull: this._nonNull,
|
|
105
|
+
nonNullList: this._nonNullList,
|
|
89
106
|
list: this._list,
|
|
90
|
-
plugins:
|
|
107
|
+
plugins: lodash_1.clone(this._plugins)
|
|
91
108
|
};
|
|
92
109
|
}
|
|
93
110
|
}
|
package/enumType.js
CHANGED
|
@@ -18,13 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.enumType = exports.EnumTypeBuilder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const clone_1 = __importDefault(require("lodash/clone"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
28
24
|
const definition_1 = require("graphql/type/definition");
|
|
29
25
|
const Builder_1 = __importStar(require("./Builder"));
|
|
30
26
|
const enumValue_1 = require("./enumValue");
|
|
@@ -50,7 +46,7 @@ class EnumTypeBuilder extends Builder_1.default {
|
|
|
50
46
|
if (builderOrName instanceof enumValue_1.EnumValueBuilder) {
|
|
51
47
|
valueBuilder = builderOrName;
|
|
52
48
|
}
|
|
53
|
-
else if (
|
|
49
|
+
else if (lodash_1.isString(builderOrName)) {
|
|
54
50
|
valueBuilder = new enumValue_1.EnumValueBuilder(builderOrName, value);
|
|
55
51
|
if (configurator) {
|
|
56
52
|
configurator(valueBuilder);
|
|
@@ -83,7 +79,8 @@ class EnumTypeBuilder extends Builder_1.default {
|
|
|
83
79
|
}
|
|
84
80
|
async finalizeEnumType(context, info) { }
|
|
85
81
|
build(context) {
|
|
86
|
-
|
|
82
|
+
const info = this.info();
|
|
83
|
+
this._executePluginsSync('beforeBuildEnumType', plugin => plugin.beforeBuildEnumType(this, context, info));
|
|
87
84
|
let builtValues = {};
|
|
88
85
|
for (let value of this._values) {
|
|
89
86
|
builtValues[value.name] = value.build(context);
|
|
@@ -94,16 +91,16 @@ class EnumTypeBuilder extends Builder_1.default {
|
|
|
94
91
|
values: builtValues,
|
|
95
92
|
extensions: Object.assign({ [Builder_1.builderInfoExtensionName]: this.info() }, Object.fromEntries(this._extensions))
|
|
96
93
|
});
|
|
97
|
-
this._executePluginsSync('afterBuildEnumType', plugin => plugin.afterBuildEnumType(this, context, enumType));
|
|
94
|
+
this._executePluginsSync('afterBuildEnumType', plugin => plugin.afterBuildEnumType(this, context, info, enumType));
|
|
98
95
|
return enumType;
|
|
99
96
|
}
|
|
100
97
|
info() {
|
|
101
98
|
return {
|
|
102
99
|
name: this.name,
|
|
103
100
|
description: this._description,
|
|
104
|
-
values:
|
|
101
|
+
values: lodash_1.clone(this._values),
|
|
105
102
|
extensions: new Map(this._extensions),
|
|
106
|
-
plugins:
|
|
103
|
+
plugins: lodash_1.clone(this._plugins)
|
|
107
104
|
};
|
|
108
105
|
}
|
|
109
106
|
}
|
package/enumValue.js
CHANGED
|
@@ -18,12 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.enumValue = exports.EnumValueBuilder = void 0;
|
|
26
|
-
const
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
27
24
|
const Builder_1 = __importStar(require("./Builder"));
|
|
28
25
|
class EnumValueBuilder extends Builder_1.default {
|
|
29
26
|
constructor(name, value = null) {
|
|
@@ -51,13 +48,14 @@ class EnumValueBuilder extends Builder_1.default {
|
|
|
51
48
|
}
|
|
52
49
|
async finalizeEnumValue(context, info) { }
|
|
53
50
|
build(context) {
|
|
54
|
-
|
|
51
|
+
const info = this.info();
|
|
52
|
+
this._executePluginsSync('beforeBuildEnumValue', plugin => plugin.beforeBuildEnumValue(this, context, info));
|
|
55
53
|
const enumValue = {
|
|
56
54
|
value: this._value,
|
|
57
55
|
description: this._description,
|
|
58
56
|
extensions: Object.assign({ [Builder_1.builderInfoExtensionName]: this.info() }, Object.fromEntries(this._extensions))
|
|
59
57
|
};
|
|
60
|
-
this._executePluginsSync('afterBuildEnumValue', plugin => plugin.afterBuildEnumValue(this, context, enumValue));
|
|
58
|
+
this._executePluginsSync('afterBuildEnumValue', plugin => plugin.afterBuildEnumValue(this, context, info, enumValue));
|
|
61
59
|
return enumValue;
|
|
62
60
|
}
|
|
63
61
|
info() {
|
|
@@ -66,7 +64,7 @@ class EnumValueBuilder extends Builder_1.default {
|
|
|
66
64
|
value: this._value,
|
|
67
65
|
description: this._description,
|
|
68
66
|
extensions: new Map(this._extensions),
|
|
69
|
-
plugins:
|
|
67
|
+
plugins: lodash_1.clone(this._plugins)
|
|
70
68
|
};
|
|
71
69
|
}
|
|
72
70
|
}
|
package/field.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export interface FieldBuilderInfo {
|
|
|
12
12
|
arguments: ArgumentBuilder[];
|
|
13
13
|
extensions: Map<string, any>;
|
|
14
14
|
nonNull: boolean;
|
|
15
|
+
nonNullList: boolean;
|
|
15
16
|
list: boolean;
|
|
16
17
|
allowedRoles: Set<string>;
|
|
17
18
|
deniedRoles: Set<string>;
|
|
@@ -25,6 +26,7 @@ export declare class FieldBuilder extends Builder<GraphQLFieldConfig<any, any>>
|
|
|
25
26
|
protected _arguments: ArgumentBuilder[];
|
|
26
27
|
protected _extensions: Map<string, any>;
|
|
27
28
|
protected _nonNull: boolean;
|
|
29
|
+
protected _nonNullList: boolean;
|
|
28
30
|
protected _list: boolean;
|
|
29
31
|
protected _allowedRoles: Set<string>;
|
|
30
32
|
protected _deniedRoles: Set<string>;
|
|
@@ -41,6 +43,8 @@ export declare class FieldBuilder extends Builder<GraphQLFieldConfig<any, any>>
|
|
|
41
43
|
nonNull(nonNull: boolean): any;
|
|
42
44
|
list(): this;
|
|
43
45
|
list(list: boolean): this;
|
|
46
|
+
nonNullList(): this;
|
|
47
|
+
nonNullList(nonNullList: boolean): this;
|
|
44
48
|
resolver(resolver: GraphQLFieldResolver<any, any>): this;
|
|
45
49
|
allow(...roles: string[]): this;
|
|
46
50
|
deny(...roles: string[]): this;
|
package/field.js
CHANGED
|
@@ -18,29 +18,34 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.field = exports.FieldBuilder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const clone_1 = __importDefault(require("lodash/clone"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
28
24
|
const graphql_1 = require("graphql");
|
|
29
25
|
const argument_1 = require("./argument");
|
|
30
26
|
const Builder_1 = __importStar(require("./Builder"));
|
|
27
|
+
const util_1 = require("./util");
|
|
31
28
|
class FieldBuilder extends Builder_1.default {
|
|
32
29
|
constructor(name, type = null) {
|
|
33
30
|
super(name);
|
|
34
31
|
this._arguments = [];
|
|
35
32
|
this._extensions = new Map();
|
|
36
33
|
this._nonNull = false;
|
|
34
|
+
this._nonNullList = false;
|
|
37
35
|
this._list = false;
|
|
38
36
|
this._allowedRoles = new Set();
|
|
39
37
|
this._deniedRoles = new Set();
|
|
40
|
-
this.
|
|
38
|
+
this.type(type);
|
|
41
39
|
}
|
|
42
40
|
type(type) {
|
|
43
|
-
|
|
41
|
+
const resolvedType = util_1.resolveType(type);
|
|
42
|
+
this._type = resolvedType.type;
|
|
43
|
+
if (resolvedType.nonNull)
|
|
44
|
+
this.nonNull();
|
|
45
|
+
if (resolvedType.list)
|
|
46
|
+
this.list();
|
|
47
|
+
if (resolvedType.nonNullList)
|
|
48
|
+
this.nonNullList();
|
|
44
49
|
return this;
|
|
45
50
|
}
|
|
46
51
|
description(description) {
|
|
@@ -56,7 +61,7 @@ class FieldBuilder extends Builder_1.default {
|
|
|
56
61
|
if (argOrName instanceof argument_1.ArgumentBuilder) {
|
|
57
62
|
argument = argOrName;
|
|
58
63
|
}
|
|
59
|
-
else if (
|
|
64
|
+
else if (lodash_1.isString(argOrName) && type) {
|
|
60
65
|
argument = new argument_1.ArgumentBuilder(argOrName, type);
|
|
61
66
|
if (configurator) {
|
|
62
67
|
configurator(argument);
|
|
@@ -76,6 +81,13 @@ class FieldBuilder extends Builder_1.default {
|
|
|
76
81
|
this._list = list;
|
|
77
82
|
return this;
|
|
78
83
|
}
|
|
84
|
+
nonNullList(nonNullList = true) {
|
|
85
|
+
if (nonNullList) {
|
|
86
|
+
this.list();
|
|
87
|
+
}
|
|
88
|
+
this._nonNullList = nonNullList;
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
79
91
|
resolver(resolver) {
|
|
80
92
|
this._resolver = resolver;
|
|
81
93
|
return this;
|
|
@@ -106,13 +118,20 @@ class FieldBuilder extends Builder_1.default {
|
|
|
106
118
|
if (!parentBuilder) {
|
|
107
119
|
throw new Builder_1.BuilderError('Build: Field needs parent builder argument to be present');
|
|
108
120
|
}
|
|
109
|
-
|
|
121
|
+
const info = this.info();
|
|
122
|
+
this._executePluginsSync('beforeBuildField', plugin => plugin.beforeBuildField(this, context, info));
|
|
110
123
|
let builtArgs = {};
|
|
111
124
|
for (let arg of this._arguments) {
|
|
112
125
|
builtArgs[arg.name] = arg.build(context);
|
|
113
126
|
}
|
|
114
|
-
let type =
|
|
127
|
+
let type = lodash_1.isString(this._type) ? context.getType(this._type) : this._type;
|
|
128
|
+
if (type === null) {
|
|
129
|
+
throw new Builder_1.BuilderError(`Type "${this._type}" of field "${this.name}" not found`);
|
|
130
|
+
}
|
|
115
131
|
if (this._list) {
|
|
132
|
+
if (this._nonNullList) {
|
|
133
|
+
type = graphql_1.GraphQLNonNull(type);
|
|
134
|
+
}
|
|
116
135
|
type = graphql_1.GraphQLList(type);
|
|
117
136
|
}
|
|
118
137
|
if (this._nonNull) {
|
|
@@ -126,7 +145,7 @@ class FieldBuilder extends Builder_1.default {
|
|
|
126
145
|
extensions: Object.assign({ allowedRoles: Array.from(this._allowedRoles), deniedRoles: Array.from(this._deniedRoles), [Builder_1.builderInfoExtensionName]: this.info() }, Object.fromEntries(this._extensions)),
|
|
127
146
|
resolve: resolver
|
|
128
147
|
};
|
|
129
|
-
this._executePluginsSync('afterBuildField', plugin => plugin.afterBuildField(this, context, field));
|
|
148
|
+
this._executePluginsSync('afterBuildField', plugin => plugin.afterBuildField(this, context, info, field));
|
|
130
149
|
return field;
|
|
131
150
|
}
|
|
132
151
|
info() {
|
|
@@ -134,14 +153,15 @@ class FieldBuilder extends Builder_1.default {
|
|
|
134
153
|
name: this.name,
|
|
135
154
|
type: this._type,
|
|
136
155
|
description: this._description,
|
|
137
|
-
arguments:
|
|
156
|
+
arguments: lodash_1.clone(this._arguments),
|
|
138
157
|
extensions: new Map(this._extensions),
|
|
139
158
|
nonNull: this._nonNull,
|
|
159
|
+
nonNullList: this._nonNullList,
|
|
140
160
|
list: this._list,
|
|
141
161
|
allowedRoles: new Set(this._allowedRoles),
|
|
142
162
|
deniedRoles: new Set(this._deniedRoles),
|
|
143
163
|
resolver: this._resolver,
|
|
144
|
-
plugins:
|
|
164
|
+
plugins: lodash_1.clone(this._plugins)
|
|
145
165
|
};
|
|
146
166
|
}
|
|
147
167
|
}
|
package/inputField.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export interface InputFieldBuilderInfo {
|
|
|
8
8
|
description?: string;
|
|
9
9
|
extensions: Map<string, any>;
|
|
10
10
|
nonNull: boolean;
|
|
11
|
+
nonNullList: boolean;
|
|
11
12
|
list: boolean;
|
|
12
13
|
plugins: Plugin[];
|
|
13
14
|
}
|
|
@@ -16,6 +17,7 @@ export declare class InputFieldBuilder extends Builder<GraphQLInputFieldConfig>
|
|
|
16
17
|
protected _description?: string;
|
|
17
18
|
protected _extensions: Map<string, any>;
|
|
18
19
|
protected _nonNull: boolean;
|
|
20
|
+
protected _nonNullList: boolean;
|
|
19
21
|
protected _list: boolean;
|
|
20
22
|
constructor(name: BuilderName, type: InputFieldType);
|
|
21
23
|
type(type: InputFieldType): this;
|
|
@@ -25,6 +27,8 @@ export declare class InputFieldBuilder extends Builder<GraphQLInputFieldConfig>
|
|
|
25
27
|
nonNull(nonNull: boolean): this;
|
|
26
28
|
list(): this;
|
|
27
29
|
list(list: boolean): this;
|
|
30
|
+
nonNullList(): this;
|
|
31
|
+
nonNullList(nonNullList: boolean): this;
|
|
28
32
|
finalizeBuilder(context: FinalizeContext): Promise<void>;
|
|
29
33
|
finalizeInputField(context: FinalizeContext, info: InputFieldBuilderInfo): Promise<void>;
|
|
30
34
|
build(context: BuildContext): GraphQLInputFieldConfig;
|
package/inputField.js
CHANGED
|
@@ -18,25 +18,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.inputField = exports.InputFieldBuilder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const clone_1 = __importDefault(require("lodash/clone"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
28
24
|
const graphql_1 = require("graphql");
|
|
29
25
|
const Builder_1 = __importStar(require("./Builder"));
|
|
26
|
+
const util_1 = require("./util");
|
|
30
27
|
class InputFieldBuilder extends Builder_1.default {
|
|
31
28
|
constructor(name, type) {
|
|
32
29
|
super(name);
|
|
33
30
|
this._extensions = new Map();
|
|
34
31
|
this._nonNull = false;
|
|
32
|
+
this._nonNullList = false;
|
|
35
33
|
this._list = false;
|
|
36
|
-
this.
|
|
34
|
+
this.type(type);
|
|
37
35
|
}
|
|
38
36
|
type(type) {
|
|
39
|
-
|
|
37
|
+
const resolvedType = util_1.resolveType(type);
|
|
38
|
+
this._type = resolvedType.type;
|
|
39
|
+
if (resolvedType.nonNull)
|
|
40
|
+
this.nonNull();
|
|
41
|
+
if (resolvedType.list)
|
|
42
|
+
this.list();
|
|
43
|
+
if (resolvedType.nonNullList)
|
|
44
|
+
this.nonNullList();
|
|
40
45
|
return this;
|
|
41
46
|
}
|
|
42
47
|
description(description) {
|
|
@@ -55,6 +60,13 @@ class InputFieldBuilder extends Builder_1.default {
|
|
|
55
60
|
this._list = list;
|
|
56
61
|
return this;
|
|
57
62
|
}
|
|
63
|
+
nonNullList(nonNullList = true) {
|
|
64
|
+
if (nonNullList) {
|
|
65
|
+
this.list();
|
|
66
|
+
}
|
|
67
|
+
this._nonNullList = nonNullList;
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
58
70
|
async finalizeBuilder(context) {
|
|
59
71
|
const info = this.info();
|
|
60
72
|
await this._executePlugins('beforeFinalizeInputField', plugin => plugin.beforeFinalizeInputField(this, context, info));
|
|
@@ -63,9 +75,13 @@ class InputFieldBuilder extends Builder_1.default {
|
|
|
63
75
|
}
|
|
64
76
|
async finalizeInputField(context, info) { }
|
|
65
77
|
build(context) {
|
|
66
|
-
|
|
67
|
-
|
|
78
|
+
const info = this.info();
|
|
79
|
+
this._executePluginsSync('beforeBuildInputField', plugin => plugin.beforeBuildInputField(this, context, info));
|
|
80
|
+
let type = lodash_1.isString(this._type) ? context.getType(this._type) : this._type;
|
|
68
81
|
if (this._list) {
|
|
82
|
+
if (this._nonNullList) {
|
|
83
|
+
type = graphql_1.GraphQLNonNull(type);
|
|
84
|
+
}
|
|
69
85
|
type = graphql_1.GraphQLList(type);
|
|
70
86
|
}
|
|
71
87
|
if (this._nonNull) {
|
|
@@ -76,7 +92,7 @@ class InputFieldBuilder extends Builder_1.default {
|
|
|
76
92
|
description: this._description,
|
|
77
93
|
extensions: Object.assign({ [Builder_1.builderInfoExtensionName]: this.info() }, Object.fromEntries(this._extensions))
|
|
78
94
|
};
|
|
79
|
-
this._executePluginsSync('afterBuildInputField', plugin => plugin.afterBuildInputField(this, context, inputField));
|
|
95
|
+
this._executePluginsSync('afterBuildInputField', plugin => plugin.afterBuildInputField(this, context, info, inputField));
|
|
80
96
|
return inputField;
|
|
81
97
|
}
|
|
82
98
|
info() {
|
|
@@ -86,8 +102,9 @@ class InputFieldBuilder extends Builder_1.default {
|
|
|
86
102
|
description: this._description,
|
|
87
103
|
extensions: new Map(this._extensions),
|
|
88
104
|
nonNull: this._nonNull,
|
|
105
|
+
nonNullList: this._nonNullList,
|
|
89
106
|
list: this._list,
|
|
90
|
-
plugins:
|
|
107
|
+
plugins: lodash_1.clone(this._plugins)
|
|
91
108
|
};
|
|
92
109
|
}
|
|
93
110
|
}
|
package/inputObjectType.js
CHANGED
|
@@ -18,13 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.inputObjectType = exports.InputObjectTypeBuilder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const clone_1 = __importDefault(require("lodash/clone"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
28
24
|
const graphql_1 = require("graphql");
|
|
29
25
|
const inputField_1 = require("./inputField");
|
|
30
26
|
const Builder_1 = __importStar(require("./Builder"));
|
|
@@ -47,7 +43,7 @@ class InputObjectTypeBuilder extends Builder_1.default {
|
|
|
47
43
|
if (fieldOrName instanceof inputField_1.InputFieldBuilder) {
|
|
48
44
|
field = fieldOrName;
|
|
49
45
|
}
|
|
50
|
-
else if (
|
|
46
|
+
else if (lodash_1.isString(fieldOrName) && type) {
|
|
51
47
|
field = new inputField_1.InputFieldBuilder(fieldOrName, type);
|
|
52
48
|
if (configurator) {
|
|
53
49
|
configurator(field);
|
|
@@ -74,7 +70,8 @@ class InputObjectTypeBuilder extends Builder_1.default {
|
|
|
74
70
|
}
|
|
75
71
|
async finalizeInputObjectType(context, info) { }
|
|
76
72
|
build(context) {
|
|
77
|
-
|
|
73
|
+
const info = this.info();
|
|
74
|
+
this._executePluginsSync('beforeBuildInputObjectType', plugin => plugin.beforeBuildInputObjectType(this, context, info));
|
|
78
75
|
const inputObjectType = new graphql_1.GraphQLInputObjectType({
|
|
79
76
|
name: this.name,
|
|
80
77
|
description: this._description,
|
|
@@ -87,16 +84,16 @@ class InputObjectTypeBuilder extends Builder_1.default {
|
|
|
87
84
|
return builtFields;
|
|
88
85
|
}
|
|
89
86
|
});
|
|
90
|
-
this._executePluginsSync('afterBuildInputObjectType', plugin => plugin.afterBuildInputObjectType(this, context, inputObjectType));
|
|
87
|
+
this._executePluginsSync('afterBuildInputObjectType', plugin => plugin.afterBuildInputObjectType(this, context, info, inputObjectType));
|
|
91
88
|
return inputObjectType;
|
|
92
89
|
}
|
|
93
90
|
info() {
|
|
94
91
|
return {
|
|
95
92
|
name: this.name,
|
|
96
93
|
description: this._description,
|
|
97
|
-
fields:
|
|
94
|
+
fields: lodash_1.clone(this._fields),
|
|
98
95
|
extensions: new Map(this._extensions),
|
|
99
|
-
plugins:
|
|
96
|
+
plugins: lodash_1.clone(this._plugins)
|
|
100
97
|
};
|
|
101
98
|
}
|
|
102
99
|
}
|
package/objectType.js
CHANGED
|
@@ -18,13 +18,9 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.objectType = exports.ObjectTypeBuilder = void 0;
|
|
26
|
-
const
|
|
27
|
-
const isString_1 = __importDefault(require("lodash/isString"));
|
|
23
|
+
const lodash_1 = require("lodash");
|
|
28
24
|
const graphql_1 = require("graphql");
|
|
29
25
|
const field_1 = require("./field");
|
|
30
26
|
const Builder_1 = __importStar(require("./Builder"));
|
|
@@ -56,7 +52,7 @@ class ObjectTypeBuilder extends Builder_1.default {
|
|
|
56
52
|
if (fieldOrName instanceof field_1.FieldBuilder) {
|
|
57
53
|
field = fieldOrName;
|
|
58
54
|
}
|
|
59
|
-
else if (
|
|
55
|
+
else if (lodash_1.isString(fieldOrName) && type) {
|
|
60
56
|
field = new field_1.FieldBuilder(fieldOrName, type);
|
|
61
57
|
if (configurator) {
|
|
62
58
|
configurator(field);
|
|
@@ -91,7 +87,8 @@ class ObjectTypeBuilder extends Builder_1.default {
|
|
|
91
87
|
}
|
|
92
88
|
async finalizeObjectType(context, info) { }
|
|
93
89
|
build(context) {
|
|
94
|
-
|
|
90
|
+
const info = this.info();
|
|
91
|
+
this._executePluginsSync('beforeBuildObjectType', plugin => plugin.beforeBuildObjectType(this, context, info));
|
|
95
92
|
const objectType = new graphql_1.GraphQLObjectType({
|
|
96
93
|
name: this.name,
|
|
97
94
|
description: this._description,
|
|
@@ -104,19 +101,19 @@ class ObjectTypeBuilder extends Builder_1.default {
|
|
|
104
101
|
return builtFields;
|
|
105
102
|
}
|
|
106
103
|
});
|
|
107
|
-
this._executePluginsSync('afterBuildObjectType', plugin => plugin.afterBuildObjectType(this, context, objectType));
|
|
104
|
+
this._executePluginsSync('afterBuildObjectType', plugin => plugin.afterBuildObjectType(this, context, info, objectType));
|
|
108
105
|
return objectType;
|
|
109
106
|
}
|
|
110
107
|
info() {
|
|
111
108
|
return {
|
|
112
109
|
name: this.name,
|
|
113
110
|
description: this._description,
|
|
114
|
-
fields:
|
|
111
|
+
fields: lodash_1.clone(this._fields),
|
|
115
112
|
extensions: new Map(this._extensions),
|
|
116
113
|
allowedRoles: new Set(this._allowedRoles),
|
|
117
114
|
deniedRoles: new Set(this._deniedRoles),
|
|
118
115
|
resolvers: this._resolvers,
|
|
119
|
-
plugins:
|
|
116
|
+
plugins: lodash_1.clone(this._plugins)
|
|
120
117
|
};
|
|
121
118
|
}
|
|
122
119
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kiwano/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"typings": "index.d.ts",
|
|
@@ -28,16 +28,19 @@
|
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/lodash": "^4.14.168",
|
|
31
|
+
"graphql": "^15.5.0",
|
|
31
32
|
"rimraf": "^3.0.2",
|
|
32
33
|
"ts-node": "9.1.1",
|
|
33
34
|
"typescript": "^4.2.3"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@graphql-tools/
|
|
37
|
-
"graphql": "^15.5.0",
|
|
37
|
+
"@graphql-tools/schema": "^8.2.0",
|
|
38
38
|
"graphql-middleware": "^6.0.5",
|
|
39
|
-
"graphql-scalars": "^1.9.0",
|
|
40
39
|
"lodash": "^4.17.21",
|
|
41
40
|
"pluralize": "^8.0.0"
|
|
42
|
-
}
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"graphql": "^14.0.0 || ^15.0.0"
|
|
44
|
+
},
|
|
45
|
+
"gitHead": "8c06d628d7cfaddff14bbd8fc08fefb1d9be0118"
|
|
43
46
|
}
|
package/plugin/MultiPlugin.d.ts
CHANGED
|
@@ -40,21 +40,21 @@ export declare class MultiPlugin implements Plugin {
|
|
|
40
40
|
afterBuild(rootBuilder: SchemaBuilder, schema: GraphQLSchema): void;
|
|
41
41
|
beforeBuildSchema(builder: SchemaBuilder): void;
|
|
42
42
|
afterBuildSchema(builder: SchemaBuilder, schema: GraphQLSchema): void;
|
|
43
|
-
beforeBuildObjectType(builder: ObjectTypeBuilder, context: BuildContext): void;
|
|
44
|
-
afterBuildObjectType(builder: ObjectTypeBuilder, context: BuildContext, objectType: GraphQLObjectType): void;
|
|
45
|
-
beforeBuildInputObjectType(builder: InputObjectTypeBuilder, context: BuildContext): void;
|
|
46
|
-
afterBuildInputObjectType(builder: InputObjectTypeBuilder, context: BuildContext, inputObjectType: GraphQLInputObjectType): void;
|
|
47
|
-
beforeBuildEnumType(builder: EnumTypeBuilder, context: BuildContext): void;
|
|
48
|
-
afterBuildEnumType(builder: EnumTypeBuilder, context: BuildContext, enumType: GraphQLEnumType): void;
|
|
49
|
-
beforeBuildEnumValue(builder: EnumValueBuilder, context: BuildContext): void;
|
|
50
|
-
afterBuildEnumValue(builder: EnumValueBuilder, context: BuildContext, enumValue: GraphQLEnumValueConfig): void;
|
|
51
|
-
beforeBuildUnionType(builder: UnionTypeBuilder, context: BuildContext): void;
|
|
52
|
-
afterBuildUnionType(builder: UnionTypeBuilder, context: BuildContext, unionType: GraphQLUnionType): void;
|
|
53
|
-
beforeBuildField(builder: FieldBuilder, context: BuildContext): void;
|
|
54
|
-
afterBuildField(builder: FieldBuilder, context: BuildContext, field: GraphQLFieldConfig<any, any>): void;
|
|
55
|
-
beforeBuildInputField(builder: InputFieldBuilder, context: BuildContext): void;
|
|
56
|
-
afterBuildInputField(builder: InputFieldBuilder, context: BuildContext, inputField: GraphQLInputFieldConfig): void;
|
|
57
|
-
beforeBuildArgument(builder: ArgumentBuilder, context: BuildContext): void;
|
|
58
|
-
afterBuildArgument(builder: ArgumentBuilder, context: BuildContext, argument: GraphQLArgumentConfig): void;
|
|
43
|
+
beforeBuildObjectType(builder: ObjectTypeBuilder, context: BuildContext, info: ObjectTypeBuilderInfo): void;
|
|
44
|
+
afterBuildObjectType(builder: ObjectTypeBuilder, context: BuildContext, info: ObjectTypeBuilderInfo, objectType: GraphQLObjectType): void;
|
|
45
|
+
beforeBuildInputObjectType(builder: InputObjectTypeBuilder, context: BuildContext, info: InputObjectTypeBuilderInfo): void;
|
|
46
|
+
afterBuildInputObjectType(builder: InputObjectTypeBuilder, context: BuildContext, info: InputObjectTypeBuilderInfo, inputObjectType: GraphQLInputObjectType): void;
|
|
47
|
+
beforeBuildEnumType(builder: EnumTypeBuilder, context: BuildContext, info: EnumTypeBuilderInfo): void;
|
|
48
|
+
afterBuildEnumType(builder: EnumTypeBuilder, context: BuildContext, info: EnumTypeBuilderInfo, enumType: GraphQLEnumType): void;
|
|
49
|
+
beforeBuildEnumValue(builder: EnumValueBuilder, context: BuildContext, info: EnumValueBuilderInfo): void;
|
|
50
|
+
afterBuildEnumValue(builder: EnumValueBuilder, context: BuildContext, info: EnumValueBuilderInfo, enumValue: GraphQLEnumValueConfig): void;
|
|
51
|
+
beforeBuildUnionType(builder: UnionTypeBuilder, context: BuildContext, info: UnionTypeBuilderInfo): void;
|
|
52
|
+
afterBuildUnionType(builder: UnionTypeBuilder, context: BuildContext, info: UnionTypeBuilderInfo, unionType: GraphQLUnionType): void;
|
|
53
|
+
beforeBuildField(builder: FieldBuilder, context: BuildContext, info: FieldBuilderInfo): void;
|
|
54
|
+
afterBuildField(builder: FieldBuilder, context: BuildContext, info: FieldBuilderInfo, field: GraphQLFieldConfig<any, any>): void;
|
|
55
|
+
beforeBuildInputField(builder: InputFieldBuilder, context: BuildContext, info: InputFieldBuilderInfo): void;
|
|
56
|
+
afterBuildInputField(builder: InputFieldBuilder, context: BuildContext, info: InputFieldBuilderInfo, inputField: GraphQLInputFieldConfig): void;
|
|
57
|
+
beforeBuildArgument(builder: ArgumentBuilder, context: BuildContext, info: ArgumentBuilderInfo): void;
|
|
58
|
+
afterBuildArgument(builder: ArgumentBuilder, context: BuildContext, info: ArgumentBuilderInfo, argument: GraphQLArgumentConfig): void;
|
|
59
59
|
}
|
|
60
60
|
export default MultiPlugin;
|