Skip to content

Commit

Permalink
fix(order): fix order by computed column SQL item bug (#741)
Browse files Browse the repository at this point in the history
Co-authored-by: Benjie Gillam <benjie@jemjie.com>
  • Loading branch information
pszafer and benjie committed May 26, 2021
1 parent 7b979e6 commit 0635ecb
Show file tree
Hide file tree
Showing 17 changed files with 67 additions and 0 deletions.
Expand Up @@ -171,6 +171,8 @@ export default (function PgMutationPayloadEdgePlugin(
? sql.fragment`${queryBuilder.getTableAlias()}.${sql.identifier(
col
)}`
: typeof col === "function"
? col({ queryBuilder })
: col;
expressions.push(expr);
});
Expand Down
Expand Up @@ -12,6 +12,7 @@ mutation {
j: deleteCompoundKeyByPersonId1AndPersonId2(input: { personId1: 2, personId2:3 }) { ...deleteCompoundKeyPayload }
k: deletePersonByEmail(input: { email: "budd.deey@email.com" }) { ...deletePersonPayload }
l: deletePersonByEmail(input: { email: "graphile-build.issue.27.exists@example.com" }) { ...deletePersonPayload2 }
m: deletePersonById(input: { id: 1 }) { ...deletePersonPayloadWithEdge }
}

fragment deletePostPayload on DeletePostPayload {
Expand Down Expand Up @@ -62,3 +63,20 @@ fragment deletePersonPayload2 on DeletePersonPayload {
}
query { nodeId }
}

fragment deletePersonPayloadWithEdge on DeletePersonPayload {
clientMutationId
deletedPersonId
personEdge(orderBy: FIRST_NAME_ASC) {
cursor
node {
firstName
id
nodeId
email
}
}
query {
nodeId
}
}
Expand Up @@ -893,6 +893,22 @@ Object {
"nodeId": "query",
},
},
"m": Object {
"clientMutationId": null,
"deletedPersonId": "WyJwZW9wbGUiLDFd",
"personEdge": Object {
"cursor": "WyJmaXJzdF9uYW1lX2FzYyIsWyJKb2huIiwxXV0=",
"node": Object {
"email": "john.smith@email.com",
"firstName": "John",
"id": 1,
"nodeId": "WyJwZW9wbGUiLDFd",
},
},
"query": Object {
"nodeId": "query",
},
},
},
"errors": Array [
[GraphQLError: No values were deleted in collection 'posts' because no values you can delete were found matching these criteria.],
Expand Down
Expand Up @@ -5751,6 +5751,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down Expand Up @@ -15948,6 +15950,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -2939,6 +2939,8 @@ type Person implements Node {
"""@deprecated This is deprecated (comment on function c.person_exists)."""
exists(email: Email): Boolean
"""@sortable"""
firstName: String
firstPost: Post
Expand Down
Expand Up @@ -5751,6 +5751,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -6086,6 +6086,8 @@ enum PeopleOrderBy {
COMPUTED_OUT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
NATURAL
Expand Down
Expand Up @@ -5766,6 +5766,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -2123,6 +2123,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -2939,6 +2939,8 @@ type Person implements Node {

"""@deprecated This is deprecated (comment on function c.person_exists)."""
exists(email: Email): Boolean

"""@sortable"""
firstName: String
firstPost: Post

Expand Down
Expand Up @@ -1771,6 +1771,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -7078,6 +7078,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -2842,6 +2842,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -2846,6 +2846,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down Expand Up @@ -7156,6 +7158,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -2862,6 +2862,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
COMPUTED_OUT_ASC
COMPUTED_OUT_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
PRIMARY_KEY_ASC
PRIMARY_KEY_DESC
}
Expand Down
Expand Up @@ -5147,6 +5147,8 @@ enum PeopleOrderBy {
CREATED_AT_DESC
EMAIL_ASC
EMAIL_DESC
FIRST_NAME_ASC
FIRST_NAME_DESC
ID_ASC
ID_DESC
LAST_LOGIN_FROM_IP_ASC
Expand Down
Expand Up @@ -369,6 +369,7 @@ create function c.no_args_mutation() returns int as $$ select 2 $$ language sql;
create function a.return_void_mutation() returns void as $$ begin return; end; $$ language plpgsql;

create function c.person_first_name(person c.person) returns text as $$ select split_part(person.person_full_name, ' ', 1) $$ language sql stable;
comment on function c.person_first_name(c.person) is E'@sortable';
create function c.person_friends(person c.person) returns setof c.person as $$ select friend.* from c.person as friend where friend.id in (person.id + 1, person.id + 2) $$ language sql stable;
comment on function c.person_friends(c.person) is E'@sortable';
create function c.person_first_post(person c.person) returns a.post as $$ select * from a.post where a.post.author_id = person.id order by id asc limit 1 $$ language sql stable;
Expand Down

0 comments on commit 0635ecb

Please sign in to comment.