Skip to content

Commit

Permalink
fix(graphql-api): fixes profiles query sorting bug
Browse files Browse the repository at this point in the history
Fixes the sort ordering using the wrong values
  • Loading branch information
anguspiv committed Jul 31, 2022
1 parent c653276 commit d1cf9af
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion schema/types/Profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export const ProfileQuery = extendType({
}

if (orderBy) {
query.orderBy = [{ [orderBy]: sort }];
query.orderBy = [{ [orderBy]: sort?.toLowerCase() === 'asc' ? 'asc' : 'desc' }];
}

return prisma.profile.findMany(query);
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/queries/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const UPDATE_PROFILE = gql`
`;

export const SEARCH_PLAYERS = gql`
query SearchPlayers($searchTerm: String, $order: String) {
profiles(searchTerm: $searchTerm, order: $order) {
query SearchPlayers($searchTerm: String, $sort: String) {
profiles(searchTerm: $searchTerm, sort: $sort) {
id
firstName
nickname
Expand Down

0 comments on commit d1cf9af

Please sign in to comment.