Skip to content

Commit c840fe2

Browse files
committed
Validate EdgeDB sort keys
1 parent bb387f0 commit c840fe2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/core/edgedb/dto.repository.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { LazyGetter as Once } from 'lazy-get-decorator';
1212
import { lowerCase } from 'lodash';
1313
import { AbstractClass } from 'type-fest';
1414
import {
15+
ClientException,
1516
DBName,
1617
EnhancedResource,
1718
EnumType,
@@ -162,7 +163,11 @@ export const RepoFor = <
162163
scope: ScopeOf<Root>,
163164
input: SortablePaginationInput,
164165
): OrderByExpression {
165-
// TODO Validate this is a valid sort key
166+
if (!(input.sort in scope.__element__.__pointers__)) {
167+
throw new ClientException(
168+
`'${input.sort}' is not a valid sort key for '${resource.name}'`,
169+
);
170+
}
166171
return {
167172
expression: (scope as any)[input.sort],
168173
direction: input.order,

0 commit comments

Comments
 (0)