diff --git a/lib/graphql/execution/runner.rb b/lib/graphql/execution/runner.rb index 3b76ddfeca..aa50dab8f6 100644 --- a/lib/graphql/execution/runner.rb +++ b/lib/graphql/execution/runner.rb @@ -155,12 +155,16 @@ def execute end query.result end - end - rescue SystemStackError => err - @multiplex.queries.map do |query| - @schema.query_stack_error(query, err) - query.result_values ||= { "errors" => query.context.errors.map(&:to_h) } - query.result + rescue SystemStackError => err + queries.map do |query| + @schema.query_stack_error(query, err) + query.result_values ||= { "errors" => query.context.errors.map(&:to_h) } + query.result + end + rescue Exception + # Assign values here so that the query's `@executed` becomes true + queries.map { |q| q.result_values ||= {} } + raise end ensure Fiber[:__graphql_current_multiplex] = previous_multiplex diff --git a/spec/graphql/analysis/query_complexity_spec.rb b/spec/graphql/analysis/query_complexity_spec.rb index 52c86ff49d..ee8c548a73 100644 --- a/spec/graphql/analysis/query_complexity_spec.rb +++ b/spec/graphql/analysis/query_complexity_spec.rb @@ -762,7 +762,11 @@ class Entity < GraphQL::Schema::Union end class Query < GraphQL::Schema::Object - field :entity, Entity, fallback_value: nil + field :entity, Entity, fallback_value: nil, resolve_static: true + + def self.entity(ctx) + nil + end end def self.resolve_type diff --git a/spec/graphql/language/sanitized_printer_spec.rb b/spec/graphql/language/sanitized_printer_spec.rb index 84702cc29d..0e5656ad7e 100644 --- a/spec/graphql/language/sanitized_printer_spec.rb +++ b/spec/graphql/language/sanitized_printer_spec.rb @@ -352,10 +352,14 @@ class Grouping < GraphQL::Schema::Enum end class Query < GraphQL::Schema::Object - field :things, [String] do + field :things, [String], resolve_static: true do argument :group, Grouping end + def self.things(ctx, group:) + [group] + end + def things(group:) [group] end diff --git a/spec/graphql/schema_spec.rb b/spec/graphql/schema_spec.rb index e22c2e47cf..9404b4df75 100644 --- a/spec/graphql/schema_spec.rb +++ b/spec/graphql/schema_spec.rb @@ -299,7 +299,8 @@ def self.use(schema_defn) query_type = Class.new(GraphQL::Schema::Object) do graphql_name 'Query' - field :foobar, Integer, null: false + field :foobar, Integer, null: false, resolve_static: true + def self.foobar(ctx); 1337; end def foobar; 1337; end end