bug(gitlab-backend): graphql api is broken
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:
- Create a DecapCMS with Gitlab self-hosted backend ;
- Configure the
use_graphiql: trueoption - See that data are loaded using REST API and that dropdown populate is broken
- 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 👏 👏 )
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.
Thank you, I will close this issue. It should be fixed.