@graphql-mesh/mysql 1.0.0-alpha-20230523160518-5443a1139 → 1.0.0-alpha-20230523160829-449dc3c14
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/cjs/index.js +13 -14
- package/esm/index.js +13 -14
- package/package.json +11 -8
package/cjs/index.js
CHANGED
|
@@ -103,10 +103,10 @@ class MySQLHandler {
|
|
|
103
103
|
return new Proxy({}, {
|
|
104
104
|
get: (_, methodName) => {
|
|
105
105
|
if (methodName === 'release') {
|
|
106
|
-
return () => promisifiedConnection
|
|
106
|
+
return () => promisifiedConnection$?.then(promisifiedConnection => promisifiedConnection?.connection.release());
|
|
107
107
|
}
|
|
108
108
|
if (methodName === 'connection') {
|
|
109
|
-
return promisifiedConnection
|
|
109
|
+
return promisifiedConnection$?.then(promisifiedConnection => promisifiedConnection?.connection);
|
|
110
110
|
}
|
|
111
111
|
return async (...args) => {
|
|
112
112
|
const cacheKey = [methodName, ...args].join('_');
|
|
@@ -175,7 +175,6 @@ class MySQLHandler {
|
|
|
175
175
|
const tableNames = this.config.tables || Object.keys(tables);
|
|
176
176
|
const typeMergingOptions = {};
|
|
177
177
|
await Promise.all(tableNames.map(async (tableName) => {
|
|
178
|
-
var _a, _b;
|
|
179
178
|
if (this.config.tables && !this.config.tables.includes(tableName)) {
|
|
180
179
|
return;
|
|
181
180
|
}
|
|
@@ -217,7 +216,7 @@ class MySQLHandler {
|
|
|
217
216
|
});
|
|
218
217
|
const primaryKeys = new Set();
|
|
219
218
|
const fields = await introspectionConnection.getTableFields(tableName);
|
|
220
|
-
const fieldNames =
|
|
219
|
+
const fieldNames = this.config.tableFields?.find(({ table }) => table === tableName)?.fields ||
|
|
221
220
|
Object.keys(fields);
|
|
222
221
|
await Promise.all(fieldNames.map(async (fieldName) => {
|
|
223
222
|
const tableField = fields[fieldName];
|
|
@@ -226,7 +225,7 @@ class MySQLHandler {
|
|
|
226
225
|
}
|
|
227
226
|
const typePattern = tableField.Type;
|
|
228
227
|
const [realTypeNameCased, restTypePattern] = typePattern.split('(');
|
|
229
|
-
const [typeDetails] =
|
|
228
|
+
const [typeDetails] = restTypePattern?.split(')') || [];
|
|
230
229
|
const realTypeName = realTypeNameCased.toLowerCase();
|
|
231
230
|
let type = SCALARS[realTypeName];
|
|
232
231
|
if (realTypeName === 'enum' || realTypeName === 'set') {
|
|
@@ -318,16 +317,16 @@ class MySQLHandler {
|
|
|
318
317
|
resolve: async (root, args, { mysqlConnection }, info) => {
|
|
319
318
|
const where = {
|
|
320
319
|
[foreignColumnName]: root[columnName],
|
|
321
|
-
...args
|
|
320
|
+
...args?.where,
|
|
322
321
|
};
|
|
323
322
|
// Generate limit statement
|
|
324
323
|
const limit = [args.limit, args.offset].filter(Boolean);
|
|
325
324
|
const fields = getFieldsFromResolveInfo(info);
|
|
326
325
|
if (limit.length) {
|
|
327
|
-
return mysqlConnection.selectLimit(foreignTableName, fields, limit, where, args
|
|
326
|
+
return mysqlConnection.selectLimit(foreignTableName, fields, limit, where, args?.orderBy);
|
|
328
327
|
}
|
|
329
328
|
else {
|
|
330
|
-
return mysqlConnection.select(foreignTableName, fields, where, args
|
|
329
|
+
return mysqlConnection.select(foreignTableName, fields, where, args?.orderBy);
|
|
331
330
|
}
|
|
332
331
|
},
|
|
333
332
|
},
|
|
@@ -356,7 +355,7 @@ class MySQLHandler {
|
|
|
356
355
|
resolve: (root, args, { mysqlConnection }, info) => {
|
|
357
356
|
const where = {
|
|
358
357
|
[columnName]: root[foreignColumnName],
|
|
359
|
-
...args
|
|
358
|
+
...args?.where,
|
|
360
359
|
};
|
|
361
360
|
const fieldMap = (0, graphql_fields_1.default)(info);
|
|
362
361
|
const fields = [];
|
|
@@ -377,10 +376,10 @@ class MySQLHandler {
|
|
|
377
376
|
// Generate limit statement
|
|
378
377
|
const limit = [args.limit, args.offset].filter(Boolean);
|
|
379
378
|
if (limit.length) {
|
|
380
|
-
return mysqlConnection.selectLimit(tableName, fields, limit, where, args
|
|
379
|
+
return mysqlConnection.selectLimit(tableName, fields, limit, where, args?.orderBy);
|
|
381
380
|
}
|
|
382
381
|
else {
|
|
383
|
-
return mysqlConnection.select(tableName, fields, where, args
|
|
382
|
+
return mysqlConnection.select(tableName, fields, where, args?.orderBy);
|
|
384
383
|
}
|
|
385
384
|
},
|
|
386
385
|
},
|
|
@@ -435,10 +434,10 @@ class MySQLHandler {
|
|
|
435
434
|
// Generate limit statement
|
|
436
435
|
const limit = [args.limit, args.offset].filter(Boolean);
|
|
437
436
|
if (limit.length) {
|
|
438
|
-
return mysqlConnection.selectLimit(tableName, fields, limit, args.where, args
|
|
437
|
+
return mysqlConnection.selectLimit(tableName, fields, limit, args.where, args?.orderBy);
|
|
439
438
|
}
|
|
440
439
|
else {
|
|
441
|
-
return mysqlConnection.select(tableName, fields, args.where, args
|
|
440
|
+
return mysqlConnection.select(tableName, fields, args.where, args?.orderBy);
|
|
442
441
|
}
|
|
443
442
|
},
|
|
444
443
|
},
|
|
@@ -500,7 +499,7 @@ class MySQLHandler {
|
|
|
500
499
|
},
|
|
501
500
|
resolve: (root, args, { mysqlConnection }) => mysqlConnection
|
|
502
501
|
.deleteRow(tableName, args.where)
|
|
503
|
-
.then(result => !!
|
|
502
|
+
.then(result => !!result?.affectedRows),
|
|
504
503
|
},
|
|
505
504
|
});
|
|
506
505
|
}));
|
package/esm/index.js
CHANGED
|
@@ -100,10 +100,10 @@ export default class MySQLHandler {
|
|
|
100
100
|
return new Proxy({}, {
|
|
101
101
|
get: (_, methodName) => {
|
|
102
102
|
if (methodName === 'release') {
|
|
103
|
-
return () => promisifiedConnection
|
|
103
|
+
return () => promisifiedConnection$?.then(promisifiedConnection => promisifiedConnection?.connection.release());
|
|
104
104
|
}
|
|
105
105
|
if (methodName === 'connection') {
|
|
106
|
-
return promisifiedConnection
|
|
106
|
+
return promisifiedConnection$?.then(promisifiedConnection => promisifiedConnection?.connection);
|
|
107
107
|
}
|
|
108
108
|
return async (...args) => {
|
|
109
109
|
const cacheKey = [methodName, ...args].join('_');
|
|
@@ -172,7 +172,6 @@ export default class MySQLHandler {
|
|
|
172
172
|
const tableNames = this.config.tables || Object.keys(tables);
|
|
173
173
|
const typeMergingOptions = {};
|
|
174
174
|
await Promise.all(tableNames.map(async (tableName) => {
|
|
175
|
-
var _a, _b;
|
|
176
175
|
if (this.config.tables && !this.config.tables.includes(tableName)) {
|
|
177
176
|
return;
|
|
178
177
|
}
|
|
@@ -214,7 +213,7 @@ export default class MySQLHandler {
|
|
|
214
213
|
});
|
|
215
214
|
const primaryKeys = new Set();
|
|
216
215
|
const fields = await introspectionConnection.getTableFields(tableName);
|
|
217
|
-
const fieldNames =
|
|
216
|
+
const fieldNames = this.config.tableFields?.find(({ table }) => table === tableName)?.fields ||
|
|
218
217
|
Object.keys(fields);
|
|
219
218
|
await Promise.all(fieldNames.map(async (fieldName) => {
|
|
220
219
|
const tableField = fields[fieldName];
|
|
@@ -223,7 +222,7 @@ export default class MySQLHandler {
|
|
|
223
222
|
}
|
|
224
223
|
const typePattern = tableField.Type;
|
|
225
224
|
const [realTypeNameCased, restTypePattern] = typePattern.split('(');
|
|
226
|
-
const [typeDetails] =
|
|
225
|
+
const [typeDetails] = restTypePattern?.split(')') || [];
|
|
227
226
|
const realTypeName = realTypeNameCased.toLowerCase();
|
|
228
227
|
let type = SCALARS[realTypeName];
|
|
229
228
|
if (realTypeName === 'enum' || realTypeName === 'set') {
|
|
@@ -315,16 +314,16 @@ export default class MySQLHandler {
|
|
|
315
314
|
resolve: async (root, args, { mysqlConnection }, info) => {
|
|
316
315
|
const where = {
|
|
317
316
|
[foreignColumnName]: root[columnName],
|
|
318
|
-
...args
|
|
317
|
+
...args?.where,
|
|
319
318
|
};
|
|
320
319
|
// Generate limit statement
|
|
321
320
|
const limit = [args.limit, args.offset].filter(Boolean);
|
|
322
321
|
const fields = getFieldsFromResolveInfo(info);
|
|
323
322
|
if (limit.length) {
|
|
324
|
-
return mysqlConnection.selectLimit(foreignTableName, fields, limit, where, args
|
|
323
|
+
return mysqlConnection.selectLimit(foreignTableName, fields, limit, where, args?.orderBy);
|
|
325
324
|
}
|
|
326
325
|
else {
|
|
327
|
-
return mysqlConnection.select(foreignTableName, fields, where, args
|
|
326
|
+
return mysqlConnection.select(foreignTableName, fields, where, args?.orderBy);
|
|
328
327
|
}
|
|
329
328
|
},
|
|
330
329
|
},
|
|
@@ -353,7 +352,7 @@ export default class MySQLHandler {
|
|
|
353
352
|
resolve: (root, args, { mysqlConnection }, info) => {
|
|
354
353
|
const where = {
|
|
355
354
|
[columnName]: root[foreignColumnName],
|
|
356
|
-
...args
|
|
355
|
+
...args?.where,
|
|
357
356
|
};
|
|
358
357
|
const fieldMap = graphqlFields(info);
|
|
359
358
|
const fields = [];
|
|
@@ -374,10 +373,10 @@ export default class MySQLHandler {
|
|
|
374
373
|
// Generate limit statement
|
|
375
374
|
const limit = [args.limit, args.offset].filter(Boolean);
|
|
376
375
|
if (limit.length) {
|
|
377
|
-
return mysqlConnection.selectLimit(tableName, fields, limit, where, args
|
|
376
|
+
return mysqlConnection.selectLimit(tableName, fields, limit, where, args?.orderBy);
|
|
378
377
|
}
|
|
379
378
|
else {
|
|
380
|
-
return mysqlConnection.select(tableName, fields, where, args
|
|
379
|
+
return mysqlConnection.select(tableName, fields, where, args?.orderBy);
|
|
381
380
|
}
|
|
382
381
|
},
|
|
383
382
|
},
|
|
@@ -432,10 +431,10 @@ export default class MySQLHandler {
|
|
|
432
431
|
// Generate limit statement
|
|
433
432
|
const limit = [args.limit, args.offset].filter(Boolean);
|
|
434
433
|
if (limit.length) {
|
|
435
|
-
return mysqlConnection.selectLimit(tableName, fields, limit, args.where, args
|
|
434
|
+
return mysqlConnection.selectLimit(tableName, fields, limit, args.where, args?.orderBy);
|
|
436
435
|
}
|
|
437
436
|
else {
|
|
438
|
-
return mysqlConnection.select(tableName, fields, args.where, args
|
|
437
|
+
return mysqlConnection.select(tableName, fields, args.where, args?.orderBy);
|
|
439
438
|
}
|
|
440
439
|
},
|
|
441
440
|
},
|
|
@@ -497,7 +496,7 @@ export default class MySQLHandler {
|
|
|
497
496
|
},
|
|
498
497
|
resolve: (root, args, { mysqlConnection }) => mysqlConnection
|
|
499
498
|
.deleteRow(tableName, args.where)
|
|
500
|
-
.then(result => !!
|
|
499
|
+
.then(result => !!result?.affectedRows),
|
|
501
500
|
},
|
|
502
501
|
});
|
|
503
502
|
}));
|
package/package.json
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-mesh/mysql",
|
|
3
|
-
"version": "1.0.0-alpha-
|
|
3
|
+
"version": "1.0.0-alpha-20230523160829-449dc3c14",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@graphql-mesh/cross-helpers": "0.4.0-alpha-
|
|
7
|
-
"@graphql-mesh/store": "1.0.0-alpha-
|
|
8
|
-
"@graphql-mesh/types": "1.0.0-alpha-
|
|
9
|
-
"@graphql-mesh/utils": "1.0.0-alpha-
|
|
10
|
-
"@graphql-tools/utils": "^9.2.1",
|
|
6
|
+
"@graphql-mesh/cross-helpers": "0.4.0-alpha-20230523160829-449dc3c14",
|
|
7
|
+
"@graphql-mesh/store": "1.0.0-alpha-20230523160829-449dc3c14",
|
|
8
|
+
"@graphql-mesh/types": "1.0.0-alpha-20230523160829-449dc3c14",
|
|
9
|
+
"@graphql-mesh/utils": "1.0.0-alpha-20230523160829-449dc3c14",
|
|
10
|
+
"@graphql-tools/utils": "^9.2.1 || ^10.0.0",
|
|
11
11
|
"graphql": "*",
|
|
12
12
|
"tslib": "^2.4.0"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@graphql-mesh/string-interpolation": "0.5.0-alpha-
|
|
16
|
-
"@graphql-tools/delegate": "^
|
|
15
|
+
"@graphql-mesh/string-interpolation": "0.5.0-alpha-20230523160829-449dc3c14",
|
|
16
|
+
"@graphql-tools/delegate": "^10.0.0",
|
|
17
17
|
"graphql-compose": "^9.0.10",
|
|
18
18
|
"graphql-fields": "^2.0.3",
|
|
19
19
|
"graphql-scalars": "^1.20.4",
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
"directory": "packages/handlers/mysql"
|
|
27
27
|
},
|
|
28
28
|
"license": "MIT",
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=16.0.0"
|
|
31
|
+
},
|
|
29
32
|
"main": "cjs/index.js",
|
|
30
33
|
"module": "esm/index.js",
|
|
31
34
|
"typings": "typings/index.d.ts",
|