Skip to content
Snippets Groups Projects
Commit c7d4ba23 authored by Brett Walker's avatar Brett Walker
Browse files

wip

parent cca6a563
No related branches found
No related tags found
No related merge requests found
......@@ -11,8 +11,8 @@ class GitlabSchema < GraphQL::Schema
AUTHENTICATED_MAX_DEPTH = 20
# use new GraphQL interpreter
use GraphQL::Execution::Interpreter
use GraphQL::Analysis::AST
# use GraphQL::Execution::Interpreter
# use GraphQL::Analysis::AST
use GraphQL::Subscriptions::ActionCableSubscriptions
use GraphQL::Pagination::Connections
......@@ -21,10 +21,10 @@ class GitlabSchema < GraphQL::Schema
use Gitlab::Graphql::GenericTracing
use Gitlab::Graphql::Timeout, max_seconds: Gitlab.config.gitlab.graphql_timeout
# query_analyzer Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer.new
# query_analyzer Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer.new
query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer
query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::RecursionAnalyzer
query_analyzer Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer.new
query_analyzer Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer.new
# query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer
# query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::RecursionAnalyzer
max_complexity DEFAULT_MAX_COMPLEXITY
max_depth DEFAULT_MAX_DEPTH
......
......@@ -12,11 +12,7 @@ def self.abilities(*abilities)
end
def self.ability_field(ability, **kword_args)
unless resolving_keywords?(kword_args)
kword_args[:resolve] ||= -> (object, args, context) do
can?(context[:current_user], ability, object, args.to_h)
end
end
create_field_resolver(ability) unless resolving_keywords?(kword_args)
permission_field(ability, **kword_args)
end
......@@ -31,6 +27,14 @@ def self.permission_field(name, **kword_args)
field(**kword_args) # rubocop:disable Graphql/Descriptions
end
def self.create_field_resolver(ability)
unless self.respond_to?(ability)
define_method :"#{ability}" do |*args|
Ability.allowed?(context[:current_user], ability, object, args.to_h)
end
end
end
def self.resolving_keywords?(arguments)
RESOLVING_KEYWORDS.intersect?(arguments.keys.to_set)
end
......
......@@ -35,6 +35,7 @@ def authorizes_object!
end
def raise_resource_not_available_error!(msg = RESOURCE_ACCESS_ERROR)
# binding.pry
raise ::Gitlab::Graphql::Errors::ResourceNotAvailable, msg
end
end
......
......@@ -15,8 +15,11 @@ def resolve(object:, arguments:, context:)
if object.is_a?(::Types::BaseObject)
type = field.owner.kind.abstract? ? object.class : field.owner
object.present(type, attrs)
# binding.pry
yield(object, arguments)
else
# TODO: error and remove
# binding.pry
# This is the legacy code-path, hit if the field has a @resolver_proc
# TODO: remove this when resolve procs are removed from the
# graphql-ruby library, and all field instrumentation is removed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment