Organization groups and projects GraphQL query not respecting `first` and `last` arguments
Summary
We use the groups and projects GraphQL queries on the organization front page (https://gitlab.com/-/organizations/default) and Groups and projects page. On gitlab.com it appears that the first
and last
arguments aren't being respected correctly. On the front page we have first
set to 5
to return only 5 groups and projects but it is returning less than 5
Steps to reproduce
Groups
- Go to https://gitlab.com/-/graphql-explorer
- Enter the following for the query
query getOrganizationGroups($id: OrganizationsOrganizationID!, $search: String, $sort: String, $first: Int, $last: Int, $before: String, $after: String) {
organization(id: $id) {
id
groups(
first: $first
search: $search
sort: $sort
last: $last
before: $before
after: $after
) {
nodes {
id
fullName
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
- Enter the following for the query variables
{
"id": "gid://gitlab/Organizations::Organization/1",
"search": "",
"sort": "updated_at_desc",
"first": 5,
"after": null,
"last": null,
"before": null
}
- Run the query and it only returns 2 groups
Projects
- Go to https://gitlab.com/-/graphql-explorer
- Enter the following for the query
query getOrganizationProjects($id: OrganizationsOrganizationID!, $search: String, $sort: String, $first: Int, $last: Int, $before: String, $after: String) {
organization(id: $id) {
id
projects(
search: $search
sort: $sort
first: $first
last: $last
before: $before
after: $after
) {
nodes {
id
nameWithNamespace
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
}
- Enter the following for the query variables
{
"id": "gid://gitlab/Organizations::Organization/1",
"search": "",
"sort": "updated_at_desc",
"first": 5,
"after": null,
"last": null,
"before": null
}
- Run the query and it only returns 4 projects (sometimes it returns 5
🤷 )
What is the current bug behavior?
Organization groups and projects GraphQL queries do not respect first
and last
arguments
What is the expected correct behavior?
Organization groups and projects GraphQL queries should respect first
and last
arguments
Relevant logs and/or screenshots
Groups
Should show 5 groups
Projects
Should show 5 projects
Output of checks
I am only seeing this bug on gitlab.com, not locally
Possible fixes
If the user is not logged in through SAML, the groups requiring SAML login are being filtered out. We need to fix this by filtering out the SAML groups if the user is not logged in with SAML before applying the limit.