diff --git a/graphql/dgraph/graphquery.go b/graphql/dgraph/graphquery.go index 5f5e1983857..f7cd9d9065b 100644 --- a/graphql/dgraph/graphquery.go +++ b/graphql/dgraph/graphquery.go @@ -217,7 +217,7 @@ func writeOrderAndPage(b *strings.Builder, query *gql.GraphQuery, root bool) { var wroteOrder, wroteFirst bool for _, ord := range query.Order { - if root { + if root || wroteOrder { x.Check2(b.WriteString(", ")) } if ord.Desc { diff --git a/graphql/resolve/query_test.yaml b/graphql/resolve/query_test.yaml index b7ae68ca705..e40a2aaa507 100644 --- a/graphql/resolve/query_test.yaml +++ b/graphql/resolve/query_test.yaml @@ -1263,6 +1263,28 @@ } } +- + name: "Deep filter with multiple order, first and offset" + gqlquery: | + query { + queryAuthor { + name + posts(filter: { title: { anyofterms: "GraphQL" } }, order: { asc: numLikes, then: { desc: title } }, first: 10, offset: 10) { + title + } + } + } + dgquery: |- + query { + queryAuthor(func: type(Author)) { + name : Author.name + posts : Author.posts @filter(anyofterms(Post.title, "GraphQL")) (orderasc: Post.numLikes, orderdesc: Post.title, first: 10, offset: 10) { + title : Post.title + dgraph.uid : uid + } + dgraph.uid : uid + } + } - name: "All Float filters work"