Skip to content

Commit 65016a8

Browse files
committed
Stringify error extensions (fixes #2246)
1 parent 7c17f05 commit 65016a8

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

lib/graphql/execution_error.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ def to_h
4848
hash.merge!(options)
4949
end
5050
if extensions
51-
hash["extensions"] ||= {}
52-
hash["extensions"].merge!(extensions)
51+
hash["extensions"] = extensions.each_with_object({}) { |(key, value), ext|
52+
ext[key.to_s] = value
53+
}
5354
end
5455
hash
5556
end

spec/graphql/query/executor_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@
232232
"message"=>"Error was handled!",
233233
"locations" => [{"line"=>1, "column"=>17}],
234234
"path"=>["error"],
235-
"extensions"=>{code: "DUMMY_ERROR"}
235+
"extensions"=>{"code" => "DUMMY_ERROR"}
236236
}
237237
]
238238
}

spec/support/dummy/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ def execution_error_with_options
419419

420420
field :execution_error_with_extensions, Integer, null: true
421421
def execution_error_with_extensions
422-
GraphQL::ExecutionError.new("Permission Denied!", extensions: { "code" => "permission_denied" })
422+
GraphQL::ExecutionError.new("Permission Denied!", extensions: { code: "permission_denied" })
423423
end
424424

425425
# To test possibly-null fields

0 commit comments

Comments
 (0)