@coderich/autograph 0.13.2 → 0.13.4
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/package.json +1 -1
- package/src/data/Resolver.js +2 -1
- package/src/query/Query.js +2 -1
- package/src/query/QueryBuilder.js +4 -4
package/package.json
CHANGED
package/src/data/Resolver.js
CHANGED
package/src/query/Query.js
CHANGED
|
@@ -32,6 +32,7 @@ module.exports = class Query {
|
|
|
32
32
|
toCacheKey() {
|
|
33
33
|
return {
|
|
34
34
|
op: this.#query.op,
|
|
35
|
+
select: this.#query.select,
|
|
35
36
|
where: this.#query.where,
|
|
36
37
|
sort: this.#query.sort,
|
|
37
38
|
joins: this.#query.joins,
|
|
@@ -76,7 +77,7 @@ module.exports = class Query {
|
|
|
76
77
|
|
|
77
78
|
const query = this.clone({
|
|
78
79
|
model: this.#model.key,
|
|
79
|
-
select:
|
|
80
|
+
select: this.#query.select.map(name => this.#model.fields[name].key),
|
|
80
81
|
input: this.#model.walk(input, node => node.value !== undefined && Object.assign(node, { key: node.field.key })),
|
|
81
82
|
where: isNative ? where : this.#model.walk(where, node => Object.assign(node, { key: node.field.key })),
|
|
82
83
|
sort: this.#model.walk(sort, node => Object.assign(node, { key: node.field.key })),
|
|
@@ -2,19 +2,21 @@ const Query = require('./Query');
|
|
|
2
2
|
const { getGQLReturnType, getGQLSelectFields, mergeDeep } = require('../service/AppService');
|
|
3
3
|
|
|
4
4
|
module.exports = class QueryBuilder {
|
|
5
|
-
#config;
|
|
6
5
|
#query;
|
|
6
|
+
#config;
|
|
7
7
|
#terminalCommands = ['one', 'many', 'count', 'save', 'delete', 'first', 'last', 'push', 'pull', 'splice'];
|
|
8
8
|
|
|
9
9
|
constructor(config) {
|
|
10
|
-
const { query } = config;
|
|
10
|
+
const { schema, query } = config;
|
|
11
11
|
|
|
12
12
|
this.#config = config;
|
|
13
|
+
const model = schema.models[query.model];
|
|
13
14
|
|
|
14
15
|
this.#query = Object.defineProperties(query, {
|
|
15
16
|
id: { writable: true, enumerable: true, value: query.id },
|
|
16
17
|
args: { writable: true, enumerable: true, value: query.args || {} },
|
|
17
18
|
flags: { writable: true, enumerable: true, value: query.flags || {} },
|
|
19
|
+
select: { writable: true, enumerable: true, value: query.select || Object.keys(model.fields) },
|
|
18
20
|
options: { writable: true, enumerable: true, value: query.options || {} },
|
|
19
21
|
});
|
|
20
22
|
|
|
@@ -41,8 +43,6 @@ module.exports = class QueryBuilder {
|
|
|
41
43
|
* For use in GraphQL resolver methods to return the "correct" response
|
|
42
44
|
*/
|
|
43
45
|
resolve(info) {
|
|
44
|
-
this.info(info);
|
|
45
|
-
|
|
46
46
|
switch (getGQLReturnType(info)) {
|
|
47
47
|
case 'array': return this.many();
|
|
48
48
|
case 'number': return this.count();
|