decap-cms icon indicating copy to clipboard operation
decap-cms copied to clipboard

bug(gitlab-backend): graphql api is broken

Open Marc-AntoineA opened this issue 1 year ago • 2 comments

Describe the bug

I tried to use DecapCMS with gitlab backend and use_graphql: true option.

I tried with two different self-hosted gitlab without API quotas.

The Gitlab API answers :

  • the correct answer if I execute direct requests (using Postman or gitlab integrated graphicl) ;
  • the correct answer If I execute query on Google Chrome without CORS security ;
  • {"data":{"project":null}} if queries are executed in "standard mode" (localhost, production, on Firefox, Chrome, etc.)

To Reproduce

Steps to reproduce the behavior. For example:

  1. Create a DecapCMS with Gitlab self-hosted backend ;
  2. Configure the use_graphiql: true option
  3. See that data are loaded using REST API and that dropdown populate is broken
  4. Check that Graphql answers are {"data":{"project":null}}

Expected behavior Everything works.

Applicable Versions: Latest.

CMS configuration I dont't have one with public Gitlab project.

Fix

I have found that Gitlab authentication header should be

Authorization: Bearer <token>

Source : https://docs.gitlab.com/api/graphql/

But in DecapCMS we use :

 authorization: this.token ? `token ${this.token}` : '',

Source : https://github.com/decaporg/decap-cms/blob/main/packages/decap-cms-backend-gitlab/src/API.ts#L246

I changed that line and rebuilt it and it works perfectly fine for me.

(and btw, it’s awesome how it's easy to dev and build DecapCMS locally 👏 👏 )

Marc-AntoineA avatar Sep 22 '25 12:09 Marc-AntoineA

This was addressed by #7855 and is included in [email protected] and [email protected]. GitLab GraphQL requests now use the Bearer authorization scheme, matching the working REST path. If this still reproduces on Decap CMS 3.14.1 or newer, please share the exact version and whether the project is public or private. Otherwise I think this can be closed.

jackspiece avatar Jul 30 '26 10:07 jackspiece

Thank you, I will close this issue. It should be fixed.

Marc-AntoineA avatar Jul 30 '26 10:07 Marc-AntoineA