Skip to content

Commit

Permalink
feat(server): add sort direction to assets (#1100)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyshx authored Aug 9, 2024
1 parent 14837e8 commit a9afa6c
Show file tree
Hide file tree
Showing 12 changed files with 161 additions and 240 deletions.
11 changes: 5 additions & 6 deletions server/e2e/gql_project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,10 @@ func TestSortByName(t *testing.T) {
requestBody := GraphQLRequest{
OperationName: "GetProjects",
Query: `
query GetProjects($teamId: ID!, $first: Int, $last: Int, $after: Cursor, $before: Cursor, $keyword: String, $sort: ProjectSort) {
query GetProjects($teamId: ID!, $pagination: Pagination, $keyword: String, $sort: ProjectSort) {
projects(
teamId: $teamId
first: $first
last: $last
after: $after
before: $before
pagination: $pagination
keyword: $keyword
sort: $sort
) {
Expand Down Expand Up @@ -167,7 +164,9 @@ func TestSortByName(t *testing.T) {
__typename
}`,
Variables: map[string]any{
"last": 5,
"pagination": map[string]any{
"last": 5,
},
"teamId": wID.String(),
"sort": map[string]string{
"field": "NAME",
Expand Down
2 changes: 0 additions & 2 deletions server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,6 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/ravilushqa/otelgqlgen v0.15.0 h1:U85nrlweMXTGaMChUViYM39/MXBZVeVVlpuHq+6eECQ=
github.com/ravilushqa/otelgqlgen v0.15.0/go.mod h1:o+1Eju0VySmgq2BP8Vupz2YrN21Bj7D7imBqu3m2uB8=
github.com/reearth/reearthx v0.0.0-20240809042445-586dfb9c441b h1:1flLX4/85flJme++BapI9bi81I1mkd2qJ5nBVpTAXY4=
github.com/reearth/reearthx v0.0.0-20240809042445-586dfb9c441b/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/reearth/reearthx v0.0.0-20240809105752-94879dbf747b h1:Vt1oXaj7pntxlQoKi/zJwvMHovlM86sYweOOx2rlH7Q=
github.com/reearth/reearthx v0.0.0-20240809105752-94879dbf747b/go.mod h1:d1WXkdCVzSoc8pl3vW9/9yKfk4fdoZQZhX8Ot8jqgnc=
github.com/robertkrimen/godocdown v0.0.0-20130622164427-0bfa04905481/go.mod h1:C9WhFzY47SzYBIvzFqSvHIR6ROgDo4TtdTuRaOMjF/s=
Expand Down
5 changes: 5 additions & 0 deletions server/gql/_shared.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ enum TextAlign {
JUSTIFY_ALL
}

enum SortDirection {
ASC
DESC
}

# Query & Mutation

type Query {
Expand Down
9 changes: 7 additions & 2 deletions server/gql/asset.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type Asset implements Node {
team: Team
}

enum AssetSortType {
enum AssetSortField {
DATE
SIZE
NAME
Expand All @@ -26,6 +26,11 @@ input RemoveAssetInput {
assetId: ID!
}

input AssetSort {
field: AssetSortField!
direction: SortDirection!
}

# Payload

type CreateAssetPayload {
Expand All @@ -51,7 +56,7 @@ type AssetEdge {
}

extend type Query{
assets(teamId: ID!, keyword: String, sort: AssetSortType, pagination: Pagination): AssetConnection!
assets(teamId: ID!, pagination: Pagination, keyword: String, sort: AssetSort): AssetConnection!
}

extend type Mutation {
Expand Down
7 changes: 1 addition & 6 deletions server/gql/project.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ enum ProjectSortField {
NAME
}

enum SortDirection {
ASC
DESC
}

# InputType

input CreateProjectInput {
Expand Down Expand Up @@ -127,7 +122,7 @@ type ProjectEdge {
}

extend type Query{
projects(teamId: ID!, includeArchived: Boolean, first: Int, last: Int, after: Cursor, before: Cursor, keyword: String, sort: ProjectSort): ProjectConnection!
projects(teamId: ID!, includeArchived: Boolean, pagination: Pagination, keyword: String, sort: ProjectSort): ProjectConnection!
checkProjectAlias(alias: String!): ProjectAliasAvailability!
}

Expand Down
Loading

0 comments on commit a9afa6c

Please sign in to comment.