@coderich/autograph 0.13.55 → 0.13.57
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 +2 -2
- package/src/data/Resolver.js +1 -0
- package/src/query/Query.js +4 -5
- package/src/schema/Schema.js +3 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coderich/autograph",
|
|
3
3
|
"main": "index.js",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.57",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"dev": "coderich-dev"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@coderich/util": "1.0.
|
|
18
|
+
"@coderich/util": "1.0.6",
|
|
19
19
|
"@graphql-tools/merge": "9.0.0",
|
|
20
20
|
"@graphql-tools/resolvers-composition": "7.0.0",
|
|
21
21
|
"@hapi/boom": "10.0.1",
|
package/src/data/Resolver.js
CHANGED
package/src/query/Query.js
CHANGED
|
@@ -48,13 +48,12 @@ module.exports = class Query {
|
|
|
48
48
|
* Transform entire query for user consumption
|
|
49
49
|
*/
|
|
50
50
|
transform(asClone = true) {
|
|
51
|
+
let { input, where, sort } = this.#query;
|
|
51
52
|
const args = { query: this.#query, resolver: this.#resolver, context: this.#context };
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.#model.transformers.sort.transform(Util.unflatten(this.#query.sort, { safe: true }), args),
|
|
57
|
-
];
|
|
54
|
+
if (['create', 'update'].includes(this.#query.crud)) input = this.#model.transformers[this.#query.crud]?.transform(Util.unflatten(this.#query.input, { safe: true }), args);
|
|
55
|
+
if (!this.#query.isNative && ['read', 'update', 'delete'].includes(this.#query.crud)) where = this.#model.transformers.where.transform(Util.unflatten(this.#query.where ?? {}, { safe: true }), args);
|
|
56
|
+
if (['read'].includes(this.#query.crud)) sort = this.#model.transformers.sort.transform(Util.unflatten(this.#query.sort, { safe: true }), args);
|
|
58
57
|
|
|
59
58
|
if (asClone) return this.clone({ input, where, sort });
|
|
60
59
|
this.#query.input = input;
|
package/src/schema/Schema.js
CHANGED
|
@@ -194,7 +194,7 @@ module.exports = class Schema {
|
|
|
194
194
|
if (node.kind === Kind.NON_NULL_TYPE) {
|
|
195
195
|
target[isList ? 'isArrayRequired' : 'isRequired'] = true;
|
|
196
196
|
} else if (node.kind === Kind.NAMED_TYPE) {
|
|
197
|
-
target.type = node.name.value;
|
|
197
|
+
target.type = target.linkTo = node.name.value;
|
|
198
198
|
} else if (node.kind === Kind.LIST_TYPE) {
|
|
199
199
|
target.isArray = true;
|
|
200
200
|
isList = true;
|
|
@@ -503,8 +503,8 @@ module.exports = class Schema {
|
|
|
503
503
|
thunks.unshift(($schema) => {
|
|
504
504
|
$field.parent = $model;
|
|
505
505
|
$field.model = $schema.models[$field.type];
|
|
506
|
+
$field.linkTo = $schema.models[$field.linkTo];
|
|
506
507
|
$field.crud = Util.uvl($field.crud, $field.model?.scope, 'crud');
|
|
507
|
-
$field.linkTo ??= $field.model;
|
|
508
508
|
$field.linkBy ??= $field.linkTo?.pkField; // This defines join logic (below) for both straight+virtual references
|
|
509
509
|
$field.fkField ??= $field.model?.pkField; // This is the fkReference field for straight references
|
|
510
510
|
$field.linkField = $field.isVirtual ? $model.fields[$model.pkField] : $field;
|
|
@@ -537,7 +537,7 @@ module.exports = class Schema {
|
|
|
537
537
|
|
|
538
538
|
if ($field.isFKReference) {
|
|
539
539
|
const to = $field.model.key;
|
|
540
|
-
const on = $field.
|
|
540
|
+
const on = $field.linkTo.fields[$field.linkBy].key;
|
|
541
541
|
const from = $field.linkField.key;
|
|
542
542
|
const as = `join_${to}`;
|
|
543
543
|
$field.join = { to, on, from, as };
|