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