Skip to content

Commit 0635ecb

Browse files
pszaferbenjie
andauthored
fix(order): fix order by computed column SQL item bug (#741)
Co-authored-by: Benjie Gillam <benjie@jemjie.com>
1 parent 7b979e6 commit 0635ecb

17 files changed

Lines changed: 67 additions & 0 deletions

packages/graphile-build-pg/src/plugins/PgMutationPayloadEdgePlugin.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,8 @@ export default (function PgMutationPayloadEdgePlugin(
171171
? sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(
172172
col
173173
)}`
174+
: typeof col === "function"
175+
? col({ queryBuilder })
174176
: col;
175177
expressions.push(expr);
176178
});

packages/postgraphile-core/__tests__/fixtures/mutations/mutation-delete.graphql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mutation {
1212
j: deleteCompoundKeyByPersonId1AndPersonId2(input: { personId1: 2, personId2:3 }) { ...deleteCompoundKeyPayload }
1313
k: deletePersonByEmail(input: { email: "budd.deey@email.com" }) { ...deletePersonPayload }
1414
l: deletePersonByEmail(input: { email: "graphile-build.issue.27.exists@example.com" }) { ...deletePersonPayload2 }
15+
m: deletePersonById(input: { id: 1 }) { ...deletePersonPayloadWithEdge }
1516
}
1617

1718
fragment deletePostPayload on DeletePostPayload {
@@ -62,3 +63,20 @@ fragment deletePersonPayload2 on DeletePersonPayload {
6263
}
6364
query { nodeId }
6465
}
66+
67+
fragment deletePersonPayloadWithEdge on DeletePersonPayload {
68+
clientMutationId
69+
deletedPersonId
70+
personEdge(orderBy: FIRST_NAME_ASC) {
71+
cursor
72+
node {
73+
firstName
74+
id
75+
nodeId
76+
email
77+
}
78+
}
79+
query {
80+
nodeId
81+
}
82+
}

packages/postgraphile-core/__tests__/integration/__snapshots__/mutations.test.js.snap

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,22 @@ Object {
893893
"nodeId": "query",
894894
},
895895
},
896+
"m": Object {
897+
"clientMutationId": null,
898+
"deletedPersonId": "WyJwZW9wbGUiLDFd",
899+
"personEdge": Object {
900+
"cursor": "WyJmaXJzdF9uYW1lX2FzYyIsWyJKb2huIiwxXV0=",
901+
"node": Object {
902+
"email": "john.smith@email.com",
903+
"firstName": "John",
904+
"id": 1,
905+
"nodeId": "WyJwZW9wbGUiLDFd",
906+
},
907+
},
908+
"query": Object {
909+
"nodeId": "query",
910+
},
911+
},
896912
},
897913
"errors": Array [
898914
[GraphQLError: No values were deleted in collection 'posts' because no values you can delete were found matching these criteria.],

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/defaultOptions.test.js.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5751,6 +5751,8 @@ enum PeopleOrderBy {
57515751
CREATED_AT_DESC
57525752
EMAIL_ASC
57535753
EMAIL_DESC
5754+
FIRST_NAME_ASC
5755+
FIRST_NAME_DESC
57545756
ID_ASC
57555757
ID_DESC
57565758
LAST_LOGIN_FROM_IP_ASC
@@ -15948,6 +15950,8 @@ enum PeopleOrderBy {
1594815950
CREATED_AT_DESC
1594915951
EMAIL_ASC
1595015952
EMAIL_DESC
15953+
FIRST_NAME_ASC
15954+
FIRST_NAME_DESC
1595115955
ID_ASC
1595215956
ID_DESC
1595315957
LAST_LOGIN_FROM_IP_ASC

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/disabledTagsNoLegacyRelations.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,6 +2939,8 @@ type Person implements Node {
29392939
29402940
"""@deprecated This is deprecated (comment on function c.person_exists)."""
29412941
exists(email: Email): Boolean
2942+
2943+
"""@sortable"""
29422944
firstName: String
29432945
firstPost: Post
29442946

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/function-clash.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5751,6 +5751,8 @@ enum PeopleOrderBy {
57515751
CREATED_AT_DESC
57525752
EMAIL_ASC
57535753
EMAIL_DESC
5754+
FIRST_NAME_ASC
5755+
FIRST_NAME_DESC
57545756
ID_ASC
57555757
ID_DESC
57565758
LAST_LOGIN_FROM_IP_ASC

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/indexes.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6086,6 +6086,8 @@ enum PeopleOrderBy {
60866086
COMPUTED_OUT_DESC
60876087
EMAIL_ASC
60886088
EMAIL_DESC
6089+
FIRST_NAME_ASC
6090+
FIRST_NAME_DESC
60896091
ID_ASC
60906092
ID_DESC
60916093
NATURAL

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/inflect-core.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5766,6 +5766,8 @@ enum PeopleOrderBy {
57665766
CREATED_AT_DESC
57675767
EMAIL_ASC
57685768
EMAIL_DESC
5769+
FIRST_NAME_ASC
5770+
FIRST_NAME_DESC
57695771
ID_ASC
57705772
ID_DESC
57715773
LAST_LOGIN_FROM_IP_ASC

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/legacyFunctionsOnly.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2123,6 +2123,8 @@ enum PeopleOrderBy {
21232123
CREATED_AT_DESC
21242124
EMAIL_ASC
21252125
EMAIL_DESC
2126+
FIRST_NAME_ASC
2127+
FIRST_NAME_DESC
21262128
ID_ASC
21272129
ID_DESC
21282130
LAST_LOGIN_FROM_IP_ASC

packages/postgraphile-core/__tests__/integration/schema/__snapshots__/legacyRelationsOnlyLegacyJsonNoTags.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,6 +2939,8 @@ type Person implements Node {
29392939
29402940
"""@deprecated This is deprecated (comment on function c.person_exists)."""
29412941
exists(email: Email): Boolean
2942+
2943+
"""@sortable"""
29422944
firstName: String
29432945
firstPost: Post
29442946

0 commit comments

Comments
 (0)