Skip to content

Commit

Permalink
Update for changes on master
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Oct 5, 2018
1 parent dcd0a97 commit 4768e2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
21 changes: 14 additions & 7 deletions lib/graphql/execution/interpreter/runtime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,17 @@ def evaluate_selections(path, owner_object, owner_type, selections, root_operati
kwarg_arguments = arguments(object, field_defn, ast_node)
# It might turn out that making arguments for every field is slow.
# If we have to cache them, we'll need a more subtle approach here.
if field_defn.extras.include?(:ast_node)
kwarg_arguments[:ast_node] = ast_node
end
if field_defn.extras.include?(:execution_errors)
kwarg_arguments[:execution_errors] = ExecutionErrors.new(context, ast_node, next_path)
field_defn.extras.each do |extra|
case extra
when :ast_node
kwarg_arguments[:ast_node] = ast_node
when :execution_errors
kwarg_arguments[:execution_errors] = ExecutionErrors.new(context, ast_node, next_path)
when :path
kwarg_arguments[:path] = next_path
else
kwarg_arguments[extra] = field_defn.fetch_extra(extra, context)
end
end

next_selections = fields.inject([]) { |memo, f| memo.concat(f.selections) }
Expand Down Expand Up @@ -276,9 +282,8 @@ def after_lazy(obj, field:, path:, eager: false)
# Wrap the execution of _this_ method with tracing,
# but don't wrap the continuation below
inner_obj = query.trace("execute_field_lazy", {field: field, path: path}) do
method_name = schema.lazy_method_name(obj)
begin
obj.public_send(method_name)
schema.sync_lazy(obj)
rescue GraphQL::ExecutionError, GraphQL::UnauthorizedError => err
yield(err)
end
Expand Down Expand Up @@ -335,6 +340,8 @@ def arg_to_value(graphql_object, arg_type, ast_value)
else
return false, nil
end
elsif ast_value.is_a?(GraphQL::Language::Nodes::NullValue)
return true, nil
elsif arg_type.is_a?(GraphQL::Schema::NonNull)
arg_to_value(graphql_object, arg_type.of_type, ast_value)
elsif arg_type.is_a?(GraphQL::Schema::List)
Expand Down
8 changes: 3 additions & 5 deletions lib/graphql/schema/field.rb
Original file line number Diff line number Diff line change
Expand Up @@ -500,13 +500,9 @@ def resolve_field_method(obj, ruby_kwargs, ctx)
end
end

private

CONTEXT_EXTRAS = [:path]

# @param ctx [GraphQL::Query::Context::FieldResolutionContext]
def fetch_extra(extra_name, ctx)
if !CONTEXT_EXTRAS.include?(extra_name) && respond_to?(extra_name)
if extra_name != :path && respond_to?(extra_name)
self.public_send(extra_name)
elsif ctx.respond_to?(extra_name)
ctx.public_send(extra_name)
Expand All @@ -515,6 +511,8 @@ def fetch_extra(extra_name, ctx)
end
end

private

NO_ARGS = {}.freeze

def public_send_field(obj, graphql_args, field_ctx)
Expand Down
4 changes: 2 additions & 2 deletions spec/support/lazy_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def int(value:, plus:)
end

def nested_sum(value:)
SumAll.new(context, value)
SumAll.new(value)
end

field :nullable_nested_sum, LazySum, null: true do
Expand All @@ -101,7 +101,7 @@ def nullable_nested_sum(value:)
if value == 13
Wrapper.new { raise GraphQL::ExecutionError.new("13 is unlucky") }
else
SumAll.new(context, value)
SumAll.new(value)
end
end

Expand Down

0 comments on commit 4768e2d

Please sign in to comment.