Bug: Decap GitLab backend is hitting GitLab GraphQL complexity limits
Describe the bug
GitLab enforces a strict GraphQL complexity limit of 250 per query. The Decap CMS GitLab backend issues blob/tree GraphQL queries that can easily exceed this limit, causing failures when fetching large collections (e.g., many files, blobs, or merge requests). This breaks functionality for users with use_graphql: true configurations and larger repositories.
This started happening between Oct 7th and 8th
To Reproduce
- Use a repository with a large number of files or blobs. (You are welcome to fork our GitLab repository - The Blog post collection calls the Author collection which is our biggest relational query)
- Set up Decap CMS with the GitLab backend and
use_graphql: truein the configuration. This wasn't really reproducible locally (git-gateway/local backend enabled), so you will need to make sure you are working with the GitLab backend enabled. - Attempt to browse or fetch collections in the CMS (e.g., media library, file listings).
- Observe GraphQL queries failing due to "complexity limit exceeded" errors from GitLab.
Expected behavior CMS should automatically paginate all collection queries and keep each page request under the complexity limit (with a safety margin). Large collections should load seamlessly, regardless of size, and maintain backward compatibility with existing configs.
Screenshots
Ex:
Applicable Versions:
- Decap CMS version:
3.7.2and3.8.4 - Git provider: GitLab
- OS: MacOS
- Browser version: Chrome 141
- Node.JS version: 22.16.0
CMS configuration
https://gitlab.com/gitlab-com/marketing/digital-experience/about-gitlab-com/-/blob/main/public/admin/blog/config.yml
Additional context
(From CoPilot):
- GitLab started enforcing GraphQL complexity limits - docs
- This affects blob/tree queries the most, but any large collection query could break
- Proposed solution:implement automatic pagination for all GraphQL collection queries, keep each request under a safety margin (e.g., 200 complexity), and add retry logic to reduce page size if needed. Maintain full backwards compatibility for existing configs using
use_graphql: true. - See Decap CMS GitLab backend code
- GitHub GraphQL API integration in Decap can be used as reference for Apollo usage and pagination patterns.
Wanted to also point out that https://github.com/decaporg/decap-cms/issues/7611 is not related. Our repository is public and didn't have this use_graphql issue.
I have the same issue following a Gitlab self-hosting update. I can bypass the bug by requesting blobs one by one (it was 90 by 90 before ^^). This solution is easy to implement but very disappointing
// packages/decap-cms-backend-gitlab/src/API.ts
readFilesGraphQL = async (files: ImplementationFile[]) => {
// ...
batch(paths, 1, slice => {
blobPromises.push(
this.graphQLClient!.query({
query: queries.blobs,
variables: {
repo: this.repo,
branch: this.branch,
paths: slice,
},
fetchPolicy: 'cache-first',
}),
);
});
However, it seems to me that the problem here is not the complexity limits (it's not new) but how Gitlab computes complexity limits for blobs.
This piece of code was added october, 8th:
def self.complexity_multiplier(args)
args[:paths].count > 1 ? 0.1 : 0
end
https://gitlab.com/gitlab-org/gitlab-foss/-/blame/master/app/graphql/resolvers/blobs_resolver.rb
It seems that the bug will be resolved by Gitlab, see this issue : https://gitlab.com/gitlab-org/gitlab/-/issues/576497
As @Marc-AntoineA mentioned above, this is resolved! Closing the issue.