dgraph-io / dgraph-io/dgraph

[BUG]: Graphql query does not honour first: when sorting

Open
#9,239 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/bug Stale
Dominant language
Go
Stars
21.8k
Forks
1.6k
Avg merge
2d 5h
Merged PRs (30d)
9

Description

What version of Dgraph are you using?

Dgraph version : v24.0.5
Dgraph codename : dgraph
Dgraph SHA-256 : 7139a5b0cf1faaf766e3ca9b6966f2893bbddf6a8261efebf4208dfb239b7a45
Commit SHA-1 : 27450c1
Commit timestamp : 2024-11-05 23:22:41 +0530
Branch : HEAD
Go version : go1.22.8
jemalloc enabled : true

Tell us a little more about your go-environment?

Not relevant

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, CPU, OS)?

Not relevant

What steps will reproduce the bug?

Create graphql schema with:
type User {
login: String!
}

Insert more than 1000 records (like 30000)
Execute graphql queries:

 Users1: queryUser(first:30000,order: { asc: login }) {
      login
  }
  Users2: queryUser(first:30000) {
      login
  }

Execute DQL queries:

query {
Users3(func:type(User),  first:30000) {
  login: User.login
}
Users4(func:type(User),orderasc:User.login, first:30000) {
  login: User.login
}
}  ```

### Expected behavior and actual result.

As mentioned at https://dgraph.io/docs/query-language/sorting/ "Sorted queries retrieve up to 1000 results by default. This can be changed with first." This works for DQL queries, but not for graphql queries - Users1 returns only 1000 records instead of expected 3000 records without a warning.
The 1000 items limit is not even mentioned for GraphQL API (as it should be): https://dgraph.io/docs/graphql/queries/order-page/

### Additional information

The issue was mentioned before:
https://discuss.dgraph.io/t/bug-dgraph-is-limiting-query-results-that-use-order-to-1000/16160

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the ordered GraphQL query against the User schema with more than 1,000 records, then compare its results with the equivalent DQL queries. Inspect the GraphQL API's order and first handling; done means Users1 honors first:30000 like the DQL query and the GraphQL ordering documentation mentions the limit.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, graphql
Domain
api, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.