Skip to content

bug(gitlab-backend): graphql api is broken #7611

@Marc-AntoineA

Description

@Marc-AntoineA

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 👏 👏 )

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions