Skip to content
Snippets Groups Projects

[graphql] Convert to using the new query interpreter runtime

Merged Brett Walker requested to merge bw-graphql-interpreter into master
2 files
+ 33
14
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 28
12
@@ -10,11 +10,9 @@ class GitlabSchema < GraphQL::Schema
DEFAULT_MAX_DEPTH = 15
AUTHENTICATED_MAX_DEPTH = 20
if Feature.enabled?(:graphql_interpreter)
use GraphQL::Execution::Interpreter
# And, when you have updated your analyzers:
use GraphQL::Analysis::AST
end
# use new GraphQL interpreter
use GraphQL::Execution::Interpreter
use GraphQL::Analysis::AST
use GraphQL::Subscriptions::ActionCableSubscriptions
use GraphQL::Pagination::Connections
@@ -23,13 +21,10 @@ class GitlabSchema < GraphQL::Schema
use Gitlab::Graphql::GenericTracing
use Gitlab::Graphql::Timeout, max_seconds: Gitlab.config.gitlab.graphql_timeout
if Feature.enabled?(:graphql_interpreter)
query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::LoggerAnalyzer
query_analyzer Gitlab::Graphql::QueryAnalyzers::AST::RecursionAnalyzer
else
query_analyzer Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer.new
query_analyzer Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer.new
end
# 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 Types::QueryType
mutation Types::MutationType
@@ -137,6 +132,27 @@ def parse_gid(global_id, ctx = {})
gid
end
# This hook is called when an object fails an `authorized?` check.
# You might report to your bug tracker here, so you can correct
# the field resolvers not to return unauthorized objects.
#
# By default, this hook just replaces the unauthorized object with `nil`.
#
# Whatever value is returned from this method will be used instead of the
# unauthorized object (accessible as `unauthorized_error.object`). If an
# error is raised, then `nil` will be used.
#
# If you want to add an error to the `"errors"` key, raise a {GraphQL::ExecutionError}
# in this hook.
#
# @param unauthorized_error [GraphQL::UnauthorizedError]
# @return [Object] The returned object will be put in the GraphQL response
def unauthorized_object(unauthorized_error)
# certain exceptions are captured, so here we're re-raising it.
# TODO: is this needed? This is more of a hcak at the moment
raise unauthorized_error
end
private
def max_query_complexity(ctx)
Loading