Skip to content

Commit

Permalink
Merge pull request #4383 from rmosolgo/timeout-trace-fix
Browse files Browse the repository at this point in the history
Fix Timeout with other Traces
  • Loading branch information
rmosolgo committed Mar 14, 2023
2 parents ded8d6c + dc2870d commit 7b95e9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/graphql/schema/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def execute_field(query:, field:, **_rest)

error
else
yield
super
end
end
end
Expand Down
9 changes: 9 additions & 0 deletions spec/graphql/schema/timeout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
require "spec_helper"

describe GraphQL::Schema::Timeout do
module OtherTrace
def execute_field(query:, **opts)
query.context[:other_trace_worked] = true
super
end
end

let(:max_seconds) { 1 }
let(:timeout_class) { GraphQL::Schema::Timeout }
let(:timeout_schema) {
Expand Down Expand Up @@ -48,6 +55,7 @@ def nested_sleep(seconds:)

schema = Class.new(GraphQL::Schema) do
query query_type
trace_with OtherTrace
end
schema.use timeout_class, max_seconds: max_seconds
schema
Expand Down Expand Up @@ -88,6 +96,7 @@ def nested_sleep(seconds:)
]
assert_equal expected_data, result["data"]
assert_equal expected_errors, result["errors"]
assert_equal true, result.context[:other_trace_worked], "It works with other traces"
end
end

Expand Down

0 comments on commit 7b95e9a

Please sign in to comment.