diff --git a/postgraphile/postgraphile/__tests__/kitchen-sink-schema.sql b/postgraphile/postgraphile/__tests__/kitchen-sink-schema.sql index c3e1dc2c6d..de63ba1a97 100644 --- a/postgraphile/postgraphile/__tests__/kitchen-sink-schema.sql +++ b/postgraphile/postgraphile/__tests__/kitchen-sink-schema.sql @@ -260,6 +260,7 @@ create table c.edge_case ( alter table c.edge_case drop column drop_me; create function c.edge_case_computed(edge_case c.edge_case) returns text as $$ select 'hello world'::text $$ language sql stable; +comment on function c.edge_case_computed is E'@sortable'; create domain a.an_int as integer; create domain b.another_int as a.an_int; diff --git a/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.json5 b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.json5 new file mode 100644 index 0000000000..c12c4bfc9c --- /dev/null +++ b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.json5 @@ -0,0 +1,26 @@ +{ + allEdgeCases: { + nodes: [ + { + computed: "hello world", + wontCastEasy: 20, + rowId: 1, + }, + { + computed: "hello world", + wontCastEasy: null, + rowId: 2, + }, + { + computed: "hello world", + wontCastEasy: -512, + rowId: 3, + }, + { + computed: "hello world", + wontCastEasy: null, + rowId: 4, + }, + ], + }, +} diff --git a/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.mermaid b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.mermaid new file mode 100644 index 0000000000..f76cb99442 --- /dev/null +++ b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.mermaid @@ -0,0 +1,53 @@ +%%{init: {'themeVariables': { 'fontSize': '12px'}}}%% +graph TD + classDef path fill:#eee,stroke:#000,color:#000 + classDef plan fill:#fff,stroke-width:1px,color:#000 + classDef itemplan fill:#fff,stroke-width:2px,color:#000 + classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000 + classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000 + classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left + + subgraph "Buckets for queries/v4/orderby-computed" + Bucket0("Bucket 0 (root)"):::bucket + Bucket1("Bucket 1 (nullableBoundary)
Deps: 11, 12

ROOT Connectionᐸ8ᐳ[12]
1: PgSelect[14]
2: PgSelectRows[15]"):::bucket + Bucket2("Bucket 2 (listItem)

ROOT __Item{2}ᐸ15ᐳ[16]"):::bucket + Bucket3("Bucket 3 (nullableBoundary)
Deps: 17

ROOT PgSelectSingle{2}ᐸedge_caseᐳ[17]"):::bucket + end + Bucket0 --> Bucket1 + Bucket1 --> Bucket2 + Bucket2 --> Bucket3 + + %% plan dependencies + Object11{{"Object[11∈0] ➊
ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan + Access9{{"Access[9∈0] ➊
ᐸ2.pgSettingsᐳ"}}:::plan + Access10{{"Access[10∈0] ➊
ᐸ2.withPgClientᐳ"}}:::plan + Access9 & Access10 --> Object11 + __Value2["__Value[2∈0] ➊
ᐸcontextᐳ"]:::plan + __Value2 --> Access9 + __Value2 --> Access10 + Connection12{{"Connection[12∈0] ➊
ᐸ8ᐳ"}}:::plan + PgSelect14[["PgSelect[14∈1] ➊
ᐸedge_caseᐳ"]]:::plan + Object11 & Connection12 --> PgSelect14 + PgSelectRows15[["PgSelectRows[15∈1] ➊"]]:::plan + PgSelect14 --> PgSelectRows15 + __Item16[/"__Item[16∈2]
ᐸ15ᐳ"\]:::itemplan + PgSelectRows15 ==> __Item16 + PgSelectSingle17{{"PgSelectSingle[17∈2]
ᐸedge_caseᐳ"}}:::plan + __Item16 --> PgSelectSingle17 + PgClassExpression19{{"PgClassExpression[19∈3]
ᐸ”c”.”edge_...ge_case__)ᐳ"}}:::plan + PgSelectSingle17 --> PgClassExpression19 + PgClassExpression20{{"PgClassExpression[20∈3]
ᐸ__edge_cas...cast_easy”ᐳ"}}:::plan + PgSelectSingle17 --> PgClassExpression20 + PgClassExpression21{{"PgClassExpression[21∈3]
ᐸ__edge_case__.”row_id”ᐳ"}}:::plan + PgSelectSingle17 --> PgClassExpression21 + + %% define steps + classDef bucket0 stroke:#696969 + class Bucket0,__Value2,Access9,Access10,Object11,Connection12 bucket0 + classDef bucket1 stroke:#00bfff + class Bucket1,PgSelect14,PgSelectRows15 bucket1 + classDef bucket2 stroke:#7f007f + class Bucket2,__Item16,PgSelectSingle17 bucket2 + classDef bucket3 stroke:#ffa500 + class Bucket3,PgClassExpression19,PgClassExpression20,PgClassExpression21 bucket3 + diff --git a/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.sql b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.sql new file mode 100644 index 0000000000..b0386fd437 --- /dev/null +++ b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.sql @@ -0,0 +1,7 @@ +select + "c"."edge_case_computed"(__edge_case__) as "0", + __edge_case__."wont_cast_easy"::text as "1", + __edge_case__."row_id"::text as "2", + __edge_case__."not_null_has_default"::text as "3" +from "c"."edge_case" as __edge_case__ +order by "c"."edge_case_computed"(__edge_case__) asc, __edge_case__."row_id" asc; \ No newline at end of file diff --git a/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.test.graphql b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.test.graphql new file mode 100644 index 0000000000..8bcdcdf72f --- /dev/null +++ b/postgraphile/postgraphile/__tests__/queries/v4/orderby-computed.test.graphql @@ -0,0 +1,11 @@ +## expect(errors).toBeFalsy(); +#> schema: ["a", "b", "c"] +{ + allEdgeCases(orderBy: [COMPUTED_ASC, ROW_ID_ASC]) { + nodes { + computed + wontCastEasy + rowId + } + } +} diff --git a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.export.mjs index dfbee784c7..5db7a296b7 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.export.mjs @@ -6524,7 +6524,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15363,6 +15366,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28110,6 +28115,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.graphql index e893f97300..1643a534c6 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.1.graphql @@ -2644,6 +2644,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.export.mjs index dfbee784c7..5db7a296b7 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.export.mjs @@ -6524,7 +6524,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15363,6 +15366,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28110,6 +28115,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.graphql index e893f97300..1643a534c6 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/defaultOptions.subscriptions.1.graphql @@ -2644,6 +2644,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.export.mjs index f1a8be5702..7e85f18bbd 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.export.mjs @@ -3875,7 +3875,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -8429,6 +8432,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -13870,6 +13875,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.graphql index e3f77e47a7..d207799153 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-autofix.1.graphql @@ -983,6 +983,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.export.mjs index 2ae95551b8..bede0cf716 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.export.mjs @@ -3874,7 +3874,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -8431,6 +8434,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -13920,6 +13925,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.graphql index 7219e134ba..5adb03feb9 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/foreignKey-smart-tag-good.1.graphql @@ -994,6 +994,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.export.mjs index 74e3a67fbb..19fdfe2176 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.export.mjs @@ -6531,7 +6531,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15406,6 +15409,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28147,6 +28152,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.graphql index 2be8638fe9..2eabae64f4 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/function-clash-with-tags-file-workaround.1.graphql @@ -2640,6 +2640,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.export.mjs index 98f661acab..7eacd992cb 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.export.mjs @@ -6525,7 +6525,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15391,6 +15394,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28138,6 +28143,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.graphql index e893f97300..1643a534c6 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/function-clash.1.graphql @@ -2644,6 +2644,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.export.mjs index 5b84f8c51c..36c8623768 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.export.mjs @@ -6667,7 +6667,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -14863,6 +14866,8 @@ type EdgeCasesEdge { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC } """A connection to a list of \`LeftArm\` values.""" @@ -25759,6 +25764,34 @@ export const plans = { return $edge.node(); } }, + EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + } + }, LeftArmsConnection: { __assertStep: ConnectionStep, totalCount($connection) { diff --git a/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.graphql index 906748e98b..00475f6945 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/indexes.1.graphql @@ -2585,6 +2585,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL } diff --git a/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.export.mjs index 71935f10ad..53dae26b61 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.export.mjs @@ -6524,7 +6524,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15368,6 +15371,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28115,6 +28120,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.graphql index 0a242dcf5e..c6f4b68b46 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/inflect-core.1.graphql @@ -2649,6 +2649,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.export.mjs index e3b975e399..86bad86fdd 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.export.mjs @@ -3863,7 +3863,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -8299,6 +8302,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -12121,6 +12126,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.graphql index 625df6adb7..7386941f05 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/noDefaultMutations.1.graphql @@ -297,6 +297,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.export.mjs index 11c3447ea4..26a1a9d7bf 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.export.mjs @@ -6524,7 +6524,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15363,6 +15366,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28110,6 +28115,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.graphql index 66b631309c..844761d39c 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/pgStrictFunctions.1.graphql @@ -2644,6 +2644,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/rbac.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/rbac.1.export.mjs index 58f9599f2a..0fa77a6d69 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/rbac.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/rbac.1.export.mjs @@ -6958,7 +6958,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {}, + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + }, canExecute: false }, description: undefined diff --git a/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.export.mjs index dfbee784c7..5db7a296b7 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.export.mjs @@ -6524,7 +6524,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15363,6 +15366,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28110,6 +28115,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.graphql index e893f97300..1643a534c6 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/rbac.ignore.1.graphql @@ -2644,6 +2644,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.export.mjs index c909291d42..7444c0cc47 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.export.mjs @@ -3863,7 +3863,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -8355,6 +8358,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -13768,6 +13773,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.graphql index 6e77e1644e..7bfd19cf50 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/relay1.1.graphql @@ -977,6 +977,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.export.mjs index abf80068ef..60b1ec8b50 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.export.mjs @@ -3863,7 +3863,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -8614,6 +8617,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -14363,6 +14368,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.graphql index d5901021d2..da47597a2e 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.1.graphql @@ -977,6 +977,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.export.mjs index f3d026d67f..71f8d44130 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.export.mjs @@ -3863,7 +3863,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -7605,6 +7608,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -12286,6 +12291,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.graphql index 5981c85816..bcf783aaea 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/simple-collections.only.1.graphql @@ -812,6 +812,8 @@ input EdgeCaseInput { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.export.mjs index dfbee784c7..5db7a296b7 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.export.mjs @@ -6524,7 +6524,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -15363,6 +15366,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -28110,6 +28115,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.graphql b/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.graphql index 6209ee686e..1050bcc8b8 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/simplePrint.graphql @@ -4064,6 +4064,8 @@ input EdgeCaseCondition { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC diff --git a/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.export.mjs index 87334c595e..1ec08fc9a9 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.export.mjs @@ -6458,7 +6458,10 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true, + behavior: ["orderBy order resource:connection:backwards"] + } }, description: undefined }, @@ -14367,6 +14370,8 @@ input EdgeCaseCondition { """Methods to use when ordering \`EdgeCase\`.""" enum EdgeCasesOrderBy { NATURAL + COMPUTED_ASC + COMPUTED_DESC NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC WONT_CAST_EASY_ASC @@ -25972,6 +25977,32 @@ export const plans = { } }, EdgeCasesOrderBy: { + COMPUTED_ASC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "asc".toUpperCase() + }); + }, + COMPUTED_DESC(queryBuilder) { + if (typeof resource_edge_case_computedPgResource.from !== "function") { + throw new Error("Invalid computed attribute 'from'"); + } + const expression = sql`${resource_edge_case_computedPgResource.from({ + placeholder: queryBuilder.alias + })}`; + queryBuilder.orderBy({ + codec: resource_edge_case_computedPgResource.codec, + fragment: expression, + direction: "desc".toUpperCase() + }); + }, NOT_NULL_HAS_DEFAULT_ASC(queryBuilder) { queryBuilder.orderBy({ attribute: "not_null_has_default", diff --git a/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.graphql b/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.graphql index 391064204f..0d7c70053f 100644 --- a/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.graphql +++ b/postgraphile/postgraphile/__tests__/schema/v4/skipNodePlugin.1.graphql @@ -2349,6 +2349,8 @@ type EdgeCasesEdge { """Methods to use when ordering `EdgeCase`.""" enum EdgeCasesOrderBy { + COMPUTED_ASC + COMPUTED_DESC NATURAL NOT_NULL_HAS_DEFAULT_ASC NOT_NULL_HAS_DEFAULT_DESC diff --git a/postgraphile/postgraphile/__tests__/schema/v5/skipNodePlugin.1.export.mjs b/postgraphile/postgraphile/__tests__/schema/v5/skipNodePlugin.1.export.mjs index a211ea2852..4b5ff14517 100644 --- a/postgraphile/postgraphile/__tests__/schema/v5/skipNodePlugin.1.export.mjs +++ b/postgraphile/postgraphile/__tests__/schema/v5/skipNodePlugin.1.export.mjs @@ -6440,7 +6440,9 @@ const registry = makeRegistry({ schemaName: "c", name: "edge_case_computed" }, - tags: {} + tags: { + sortable: true + } }, description: undefined },