Skip to content

Commit

Permalink
fix: sort direction type resolution (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
davenewza authored Sep 13, 2024
1 parent c93211a commit 78e05d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions node/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ func writeFindManyParamsInterface(w *codegen.Writer, model *proto.Model) {
})

for i, f := range relevantFields {
w.Writef("%s?: SortDirection", f.Name)
w.Writef("%s?: runtime.SortDirection", f.Name)

if i < len(relevantFields)-1 {
w.Write(",")
Expand Down Expand Up @@ -1721,10 +1721,10 @@ func toTypeScriptType(t *proto.TypeInfo, includeCompatibleTypes bool, isTestingP
ret = t.ModelName.Value
}
case proto.Type_TYPE_SORT_DIRECTION:
if isTestingPackage {
ret = "sdk.SortDirection"
} else {
if isClientPackage {
ret = "SortDirection"
} else {
ret = "runtime.SortDirection"
}
case proto.Type_TYPE_UNION:
// Retrieve all the types that can satisfy this union field.
Expand Down
22 changes: 11 additions & 11 deletions node/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,15 @@ func TestModelAPIFindManyDeclaration(t *testing.T) {
t.Parallel()
expected := `
export type PersonOrderBy = {
firstName?: SortDirection,
lastName?: SortDirection,
age?: SortDirection,
dateOfBirth?: SortDirection,
gender?: SortDirection,
hasChildren?: SortDirection,
id?: SortDirection,
createdAt?: SortDirection,
updatedAt?: SortDirection
firstName?: runtime.SortDirection,
lastName?: runtime.SortDirection,
age?: runtime.SortDirection,
dateOfBirth?: runtime.SortDirection,
gender?: runtime.SortDirection,
hasChildren?: runtime.SortDirection,
id?: runtime.SortDirection,
createdAt?: runtime.SortDirection,
updatedAt?: runtime.SortDirection
}
export interface PersonFindManyParams {
Expand Down Expand Up @@ -1272,10 +1272,10 @@ export interface ListPeopleWhere {
favouriteSport: SportQueryInput;
}
export interface ListPeopleOrderByName {
name: SortDirection;
name: runtime.SortDirection;
}
export interface ListPeopleOrderByFavouriteSport {
favouriteSport: SortDirection;
favouriteSport: runtime.SortDirection;
}
export interface ListPeopleInput {
where: ListPeopleWhere;
Expand Down

0 comments on commit 78e05d3

Please sign in to comment.