Commit aef340f4 authored by Mathieu Parent's avatar Mathieu Parent

Fix GraphiQL when GitLab is installed under a relative URL

When installing GitLab under a relative URL [1], GraphiQL should use a
relative URL too for GraphQL.

[1]: https://docs.gitlab.com/ee/install/relative_url.html
parent bb43a021
---
title: Fix GraphiQL when GitLab is installed under a relative URL
merge_request: 23143
author: Mathieu Parent
type: fixed
post '/api/graphql', to: 'graphql#execute'
mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql'
mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: Gitlab::Utils.append_path(Gitlab.config.gitlab.relative_url_root, '/api/graphql')
::API::API.logger Rails.logger # rubocop:disable Gitlab/RailsLogger
mount ::API::API => '/'
# frozen_string_literal: true
require 'spec_helper'
describe 'GraphiQL' do
context 'without relative_url_root' do
before do
visit '/-/graphql-explorer'
end
it 'has the correct graphQLEndpoint' do
expect(page.body).to include('var graphQLEndpoint = "/api/graphql";')
end
end
context 'with relative_url_root' do
before do
stub_config_setting(relative_url_root: '/gitlab/root')
Rails.application.reload_routes!
visit '/-/graphql-explorer'
end
after do
Rails.application.reload_routes!
end
it 'has the correct graphQLEndpoint' do
expect(page.body).to include('var graphQLEndpoint = "/gitlab/root/api/graphql";')
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment