graphql-engine icon indicating copy to clipboard operation
graphql-engine copied to clipboard

[Relay] Row limit not working properly when adding `first` to relay graphql query

Open matheus1lva opened this issue 4 years ago • 6 comments

Version Information

Server Version: hasura/graphql-engine:v2.0.10.cli-migrations-v3

Environment

  • docker on ubuntu 20;
  • using relay endpoint;

What is the expected behaviour?

Having a row limit on a role set to 20

Querying for data:

{
	users_connection(first: 30) {
		edges {
			node {
				id
				name
				avatarUrl
				login
				url
			}
		}
		pageInfo {
			endCursor
			hasNextPage
		}
	}
}

I expected it to show 30 rows, has a next page, since the database has more values than the 30 asked!

Keywords

row limit, pagination with row limit, pagination override.

What is the current behaviour?

It returns only 20 rows, instead of 50, and have no next pages metadata for relay.

matheus1lva avatar Feb 03 '22 15:02 matheus1lva

To be clear, this only happens with relay, if you try to grab more results past the 19th cursor, it shows as null and does not show the hasNextPage info on pageInfo

image

The same thing does not work for the normal api

matheus1lva avatar Feb 03 '22 17:02 matheus1lva

Is this happening on version 2.2.0?

arjunyel avatar Feb 03 '22 19:02 arjunyel

Yes, the pageInfo still sends hasNextPage as false!

matheus1lva avatar Feb 03 '22 20:02 matheus1lva

Tested this, able to reproduce. It looks like the roles' row limit is being treated as the total number of rows, which is incorrect. To reproduce this:

  • set a row limit on a role
  • query a table using the relay api, set the first argument equal or greater than the row limit
  • the hasNextPage value will be false.

Do note: the row limit is intended to override the desired amount of rows specified using first. However users should still be able to paginate beyond the maximum amount of rows they are allowed to query at once.

Therefore your query returning 20 rows is expected behavior. However you should be able to paginate to page 2 and 3, with 20 and 10 rows each respectively (assuming there are a total of 50 selectable rows)

BenoitRanque avatar Feb 04 '22 13:02 BenoitRanque

Yes @BenoitRanque, setting a limit on the table breaks pagination.

joanrodriguez avatar Feb 04 '22 13:02 joanrodriguez

I can reproduce this issue. It works fine if I leave the row limit blank for a given role (which is not ideal)

PedroBern avatar Oct 17 '22 21:10 PedroBern