@snowtop/ent 0.1.0-alpha102 → 0.1.0-alpha103
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.
|
@@ -7,6 +7,7 @@ interface CustomClauseQueryOptions<TDest extends Ent<TViewer>, TViewer extends V
|
|
|
7
7
|
name: string;
|
|
8
8
|
sortColumn?: string;
|
|
9
9
|
sortColumnUnique?: boolean;
|
|
10
|
+
orderByDirection?: "asc" | "desc";
|
|
10
11
|
disableTransformations?: boolean;
|
|
11
12
|
}
|
|
12
13
|
export declare class CustomClauseQuery<TDest extends Ent<TViewer>, TViewer extends Viewer = Viewer> extends BaseEdgeQuery<any, TDest, Data> {
|
|
@@ -21,11 +21,16 @@ function getClause(opts) {
|
|
|
21
21
|
}
|
|
22
22
|
class CustomClauseQuery extends query_1.BaseEdgeQuery {
|
|
23
23
|
constructor(viewer, options) {
|
|
24
|
-
|
|
24
|
+
let sortCol = options.sortColumn || "id";
|
|
25
25
|
let unique = options.sortColumnUnique
|
|
26
26
|
? sortCol
|
|
27
27
|
: options.loadEntOptions.loaderFactory.options?.key || "id";
|
|
28
|
-
|
|
28
|
+
// pass direction to base class since it uses it
|
|
29
|
+
// this API needs to be cleaned up...
|
|
30
|
+
if (options.orderByDirection) {
|
|
31
|
+
sortCol = `${sortCol} ${options.orderByDirection}`;
|
|
32
|
+
}
|
|
33
|
+
super(viewer, sortCol, unique);
|
|
29
34
|
this.viewer = viewer;
|
|
30
35
|
this.options = options;
|
|
31
36
|
this.clause = getClause(options);
|
|
@@ -53,7 +58,8 @@ class CustomClauseQuery extends query_1.BaseEdgeQuery {
|
|
|
53
58
|
async loadRawIDs(_addID) { }
|
|
54
59
|
async loadRawData(_infos, options) {
|
|
55
60
|
if (!options.orderby) {
|
|
56
|
-
|
|
61
|
+
const direction = this.options.orderByDirection ?? "desc";
|
|
62
|
+
options.orderby = `${this.options.sortColumn} ${direction}`;
|
|
57
63
|
}
|
|
58
64
|
if (!options.limit) {
|
|
59
65
|
options.limit = ent_1.DefaultLimit;
|
package/graphql/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { gqlFieldOptions, gqlObjectOptions, gqlField, gqlArg, gqlArgType, gqlInputObjectType, gqlObjectType, gqlQuery, gqlMutation, gqlContextType, gqlConnection, GraphQLConnection, GQLCapture, gqlFileUpload, CustomType, } from "./graphql";
|
|
2
2
|
export { GraphQLTime } from "./scalars/time";
|
|
3
|
+
export { GraphQLOrderBy } from "./scalars/orderby";
|
|
3
4
|
export { GraphQLPageInfo } from "./query/page_info";
|
|
4
5
|
export { GraphQLEdge, GraphQLEdgeConnection } from "./query/edge_connection";
|
|
5
6
|
export { GraphQLEdgeType, GraphQLConnectionType, } from "./query/connection_type";
|
package/graphql/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.transformUnionTypes = exports.encodeGQLID = exports.mustDecodeNullableIDFromGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = exports.GraphQLEdgeInterface = exports.GraphQLConnectionInterface = exports.GraphQLNodeInterface = exports.GraphQLConnectionType = exports.GraphQLEdgeType = exports.GraphQLEdgeConnection = exports.GraphQLPageInfo = exports.GraphQLTime = exports.gqlFileUpload = exports.GQLCapture = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = void 0;
|
|
3
|
+
exports.transformUnionTypes = exports.encodeGQLID = exports.mustDecodeNullableIDFromGQLID = exports.mustDecodeIDFromGQLID = exports.nodeIDEncoder = exports.resolveID = exports.clearResolvers = exports.registerResolver = exports.EntNodeResolver = exports.GraphQLEdgeInterface = exports.GraphQLConnectionInterface = exports.GraphQLNodeInterface = exports.GraphQLConnectionType = exports.GraphQLEdgeType = exports.GraphQLEdgeConnection = exports.GraphQLPageInfo = exports.GraphQLOrderBy = exports.GraphQLTime = exports.gqlFileUpload = exports.GQLCapture = exports.gqlConnection = exports.gqlContextType = exports.gqlMutation = exports.gqlQuery = exports.gqlObjectType = exports.gqlInputObjectType = exports.gqlArgType = exports.gqlArg = exports.gqlField = void 0;
|
|
4
4
|
var graphql_1 = require("./graphql");
|
|
5
5
|
Object.defineProperty(exports, "gqlField", { enumerable: true, get: function () { return graphql_1.gqlField; } });
|
|
6
6
|
Object.defineProperty(exports, "gqlArg", { enumerable: true, get: function () { return graphql_1.gqlArg; } });
|
|
@@ -15,6 +15,8 @@ Object.defineProperty(exports, "GQLCapture", { enumerable: true, get: function (
|
|
|
15
15
|
Object.defineProperty(exports, "gqlFileUpload", { enumerable: true, get: function () { return graphql_1.gqlFileUpload; } });
|
|
16
16
|
var time_1 = require("./scalars/time");
|
|
17
17
|
Object.defineProperty(exports, "GraphQLTime", { enumerable: true, get: function () { return time_1.GraphQLTime; } });
|
|
18
|
+
var orderby_1 = require("./scalars/orderby");
|
|
19
|
+
Object.defineProperty(exports, "GraphQLOrderBy", { enumerable: true, get: function () { return orderby_1.GraphQLOrderBy; } });
|
|
18
20
|
var page_info_1 = require("./query/page_info");
|
|
19
21
|
Object.defineProperty(exports, "GraphQLPageInfo", { enumerable: true, get: function () { return page_info_1.GraphQLPageInfo; } });
|
|
20
22
|
var edge_connection_1 = require("./query/edge_connection");
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GraphQLOrderBy = void 0;
|
|
4
|
+
const graphql_1 = require("graphql");
|
|
5
|
+
exports.GraphQLOrderBy = new graphql_1.GraphQLEnumType({
|
|
6
|
+
name: "OrderBy",
|
|
7
|
+
values: {
|
|
8
|
+
ASC: {
|
|
9
|
+
value: "asc",
|
|
10
|
+
},
|
|
11
|
+
DESC: {
|
|
12
|
+
value: "desc",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|