File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,9 @@ class Schema
3838 # @api private
3939 class Warden
4040 def self . from_context ( context )
41- context . warden # this might be a hash which won't respond to this
42- rescue
41+ context . warden || PassThruWarden
42+ rescue NoMethodError
43+ # this might be a hash which won't respond to #warden
4344 PassThruWarden
4445 end
4546
Original file line number Diff line number Diff line change @@ -961,4 +961,15 @@ def self.visible?(member, context)
961961 end
962962 end
963963 end
964+
965+ describe "PassThruWarden is used when no warden is used" do
966+ it "uses PassThruWarden when a hash is used for context" do
967+ assert_equal GraphQL ::Schema ::Warden ::PassThruWarden , GraphQL ::Schema ::Warden . from_context ( { } )
968+ end
969+
970+ it "uses PassThruWarden when a warden on the context nor query" do
971+ context = GraphQL ::Query ::Context . new ( query : OpenStruct . new ( schema : GraphQL ::Schema . new ) , values : { } , object : nil )
972+ assert_equal GraphQL ::Schema ::Warden ::PassThruWarden , GraphQL ::Schema ::Warden . from_context ( context )
973+ end
974+ end
964975end
You can’t perform that action at this time.
0 commit comments