cormo-graphql 0.9.3 → 1.0.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.
- package/lib/decorators.js +5 -1
- package/lib/index.js +5 -1
- package/lib/schema.js +25 -6
- package/package.json +16 -15
package/lib/decorators.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/lib/schema.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -58,6 +62,9 @@ function getGraphQlType(property) {
|
|
|
58
62
|
function createSingleType(model_class, options) {
|
|
59
63
|
const fields = {};
|
|
60
64
|
for (const [column, property] of Object.entries(model_class._schema)) {
|
|
65
|
+
if (!property) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
61
68
|
const graphql_type = getGraphQlType(property);
|
|
62
69
|
if (graphql_type) {
|
|
63
70
|
const description = column === 'id' ? options.id_description : property.description;
|
|
@@ -130,6 +137,9 @@ function createListType(model_class, options, single_type) {
|
|
|
130
137
|
function createCreateInputType(model_class, options) {
|
|
131
138
|
const fields = {};
|
|
132
139
|
for (const [column, property] of Object.entries(model_class._schema)) {
|
|
140
|
+
if (!property) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
133
143
|
if (column === 'id') {
|
|
134
144
|
continue;
|
|
135
145
|
}
|
|
@@ -156,6 +166,9 @@ function createCreateInputType(model_class, options) {
|
|
|
156
166
|
function createUpdateInputType(model_class, options) {
|
|
157
167
|
const fields = {};
|
|
158
168
|
for (const [column, property] of Object.entries(model_class._schema)) {
|
|
169
|
+
if (!property) {
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
159
172
|
if (column === options.created_at_column) {
|
|
160
173
|
continue;
|
|
161
174
|
}
|
|
@@ -187,9 +200,12 @@ function createDeleteInputType(model_class, options) {
|
|
|
187
200
|
name: `Delete${model_class.name}Input`,
|
|
188
201
|
});
|
|
189
202
|
}
|
|
190
|
-
function createOrderType(model_class,
|
|
203
|
+
function createOrderType(model_class, _options) {
|
|
191
204
|
const values = {};
|
|
192
205
|
for (const [column, property] of Object.entries(model_class._schema)) {
|
|
206
|
+
if (!property) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
193
209
|
if (column === 'id' ||
|
|
194
210
|
property.type_class === cormo.types.String ||
|
|
195
211
|
property.type_class === cormo.types.Integer ||
|
|
@@ -210,6 +226,9 @@ function createOrderType(model_class, options) {
|
|
|
210
226
|
function buildListQueryArgs(model_class, options) {
|
|
211
227
|
const list_query_args = {};
|
|
212
228
|
for (const [column, property] of Object.entries(model_class._schema)) {
|
|
229
|
+
if (!property) {
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
213
232
|
if (column === 'id') {
|
|
214
233
|
list_query_args[column + '_list'] = {
|
|
215
234
|
type: new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(graphql_1.GraphQLID)),
|
|
@@ -284,7 +303,7 @@ function createDefaultCrudSchema(model_class, options = {}) {
|
|
|
284
303
|
type: create_input_type,
|
|
285
304
|
},
|
|
286
305
|
},
|
|
287
|
-
async resolve(source, args
|
|
306
|
+
async resolve(source, args) {
|
|
288
307
|
const data = args.input;
|
|
289
308
|
const date = Date.now();
|
|
290
309
|
if (options.created_at_column) {
|
|
@@ -303,7 +322,7 @@ function createDefaultCrudSchema(model_class, options = {}) {
|
|
|
303
322
|
type: update_input_type,
|
|
304
323
|
},
|
|
305
324
|
},
|
|
306
|
-
async resolve(
|
|
325
|
+
async resolve(_source, args) {
|
|
307
326
|
const data = args.input;
|
|
308
327
|
const date = Date.now();
|
|
309
328
|
if (options.updated_at_column) {
|
|
@@ -320,7 +339,7 @@ function createDefaultCrudSchema(model_class, options = {}) {
|
|
|
320
339
|
type: delete_input_type,
|
|
321
340
|
},
|
|
322
341
|
},
|
|
323
|
-
async resolve(source, args
|
|
342
|
+
async resolve(source, args) {
|
|
324
343
|
const delete_count = await model_class.find(args.input.id).delete();
|
|
325
344
|
if (delete_count === 0) {
|
|
326
345
|
throw new Error('not found');
|
|
@@ -356,7 +375,7 @@ function createDefaultCrudSchema(model_class, options = {}) {
|
|
|
356
375
|
[snake_name + '_list']: {
|
|
357
376
|
args: list_query_args,
|
|
358
377
|
description: `List query for ${camel_name}`,
|
|
359
|
-
resolve(source, args
|
|
378
|
+
resolve(source, args) {
|
|
360
379
|
return { __args: args };
|
|
361
380
|
},
|
|
362
381
|
type: new graphql_1.GraphQLNonNull(list_type),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cormo-graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "GraphQL support for CORMO",
|
|
5
5
|
"main": "./lib",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -24,23 +24,24 @@
|
|
|
24
24
|
},
|
|
25
25
|
"homepage": "https://github.com/croquiscom/cormo",
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@croquiscom/crary-graphql": "^0.
|
|
28
|
-
"cormo": "^0.
|
|
29
|
-
"graphql": "^16.
|
|
27
|
+
"@croquiscom/crary-graphql": "^1.0.0",
|
|
28
|
+
"cormo": "^1.0.0",
|
|
29
|
+
"graphql": "^16.6.0",
|
|
30
30
|
"lodash": "^4.17.21"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@types/chai": "^4.3.
|
|
34
|
-
"@types/lodash": "^4.14.
|
|
35
|
-
"@types/mocha": "^
|
|
36
|
-
"@types/node": "^
|
|
37
|
-
"@types/sinon": "^10.0.
|
|
38
|
-
"chai": "^4.3.
|
|
39
|
-
"mocha": "^
|
|
33
|
+
"@types/chai": "^4.3.4",
|
|
34
|
+
"@types/lodash": "^4.14.191",
|
|
35
|
+
"@types/mocha": "^10.0.1",
|
|
36
|
+
"@types/node": "^18.11.11",
|
|
37
|
+
"@types/sinon": "^10.0.13",
|
|
38
|
+
"chai": "^4.3.7",
|
|
39
|
+
"mocha": "^10.1.0",
|
|
40
40
|
"mysql": "^2.18.1",
|
|
41
41
|
"rimraf": "^3.0.2",
|
|
42
|
-
"sinon": "^
|
|
43
|
-
"ts-node": "^10.
|
|
44
|
-
"typescript": "^4.
|
|
45
|
-
}
|
|
42
|
+
"sinon": "^15.0.0",
|
|
43
|
+
"ts-node": "^10.9.1",
|
|
44
|
+
"typescript": "^4.9.4"
|
|
45
|
+
},
|
|
46
|
+
"gitHead": "012c58745515c8b36ffdb14b772348705b8b7ab7"
|
|
46
47
|
}
|