Enable GraphQL API endpoint

This commit is contained in:
Phil Hughes 2018-12-13 10:12:13 +00:00
parent 2bb468d6b9
commit 744f6ed12b
No known key found for this signature in database
GPG key ID: 32245528C52E0F9F
5 changed files with 11 additions and 7 deletions

View file

@ -43,6 +43,6 @@ class GraphqlController < ApplicationController
end
def check_graphql_feature_flag!
render_404 unless Feature.enabled?(:graphql, default_enabled: true)
render_404 unless Gitlab::Graphql.enabled?
end
end

View file

@ -17,7 +17,7 @@
= render 'shared/issuable/form/template_selector', issuable: issuable
= render 'shared/issuable/form/title', issuable: issuable, form: form, has_wip_commits: commits && commits.detect(&:work_in_progress?)
- if Feature.enabled?(:graphql, default_enabled: true)
- if Gitlab::Graphql.enabled?
#js-suggestions{ data: { project_path: @project.full_path } }
= render 'shared/form_elements/description', model: issuable, form: form, project: project

View file

@ -1,4 +1,4 @@
constraints(::Constraints::FeatureConstrainer.new(:graphql)) do
constraints(::Constraints::FeatureConstrainer.new(:graphql, nil, true)) do
post '/api/graphql', to: 'graphql#execute'
mount GraphiQL::Rails::Engine, at: '/-/graphql-explorer', graphql_path: '/api/graphql'
end

View file

@ -2,14 +2,14 @@
module Constraints
class FeatureConstrainer
attr_reader :feature
attr_reader :feature, :thing, :default_enabled
def initialize(feature)
@feature = feature
def initialize(feature, thing, default_enabled)
@feature, @thing, @default_enabled = feature, thing, default_enabled
end
def matches?(_request)
Feature.enabled?(feature)
Feature.enabled?(feature, @thing, default_enabled: true)
end
end
end

View file

@ -3,5 +3,9 @@
module Gitlab
module Graphql
StandardGraphqlError = Class.new(StandardError)
def self.enabled?
Feature.enabled?(:graphql, default_enabled: true)
end
end
end