Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi Order By Allow Using Fields Queried via Join Tables #559

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions entgql/internal/todo/todo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2698,6 +2698,56 @@ func TestOrderByEdgeCount(t *testing.T) {
}
})

t.Run("MultiOrderWithPagination", func(t *testing.T) {
var (
// language=GraphQL
query = `query CategoryByTodosCount($first: Int, $after: Cursor) {
categories(
first: $first,
after: $after
orderBy: [{field: TODOS_COUNT, direction: DESC}],
) {
edges {
cursor
node {
id
text
}
}
}
}`
rsp struct {
Categories struct {
Edges []struct {
Cursor string
Node struct {
ID string
Text string
}
}
}
}
)
gqlc.MustPost(
query,
&rsp,
client.Var("first", 2),
client.Var("after", nil),
)
require.Len(t, rsp.Categories.Edges, 2)

// Do another query to get the next node after the first in our original query.
expectedNode := rsp.Categories.Edges[1].Node
gqlc.MustPost(
query,
&rsp,
client.Var("first", 1),
client.Var("after", rsp.Categories.Edges[0].Cursor),
)
require.Len(t, rsp.Categories.Edges, 1)
require.Equal(t, expectedNode.ID, rsp.Categories.Edges[0].Node.ID)
})

t.Run("NestedEdgeCountOrdering", func(t *testing.T) {
var (
// language=GraphQL
Expand Down
24 changes: 20 additions & 4 deletions entgql/pagination.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.