Module: GraphQL::Schema::Member::HasArguments::ArgumentObjectLoader Private
- Included in:
- InputObject
- Defined in:
- lib/graphql/schema/member/has_arguments.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #authorize_application_object(argument, id, context, loaded_application_object) ⇒ Object private
- #load_and_authorize_application_object(argument, id, context) ⇒ Object private
- #load_application_object(argument, id, context) ⇒ Object private
- #load_application_object_failed(err) ⇒ Object private
-
#object_from_id(type, id, context) ⇒ Object
private
Look up the corresponding object for a provided ID.
Instance Method Details
#authorize_application_object(argument, id, context, loaded_application_object) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/graphql/schema/member/has_arguments.rb', line 276 def (argument, id, context, loaded_application_object) context.schema.after_lazy(loaded_application_object) do |application_object| if application_object.nil? err = GraphQL::LoadApplicationObjectFailedError.new(argument: argument, id: id, object: application_object) load_application_object_failed(err) end # Double-check that the located object is actually of this type # (Don't want to allow arbitrary access to objects this way) resolved_application_object_type = context.schema.resolve_type(argument.loads, application_object, context) context.schema.after_lazy(resolved_application_object_type) do |application_object_type| possible_object_types = context.warden.possible_types(argument.loads) if !possible_object_types.include?(application_object_type) err = GraphQL::LoadApplicationObjectFailedError.new(argument: argument, id: id, object: application_object) load_application_object_failed(err) else # This object was loaded successfully # and resolved to the right type, # now apply the `.authorized?` class method if there is one if (class_based_type = application_object_type.type_class) context.schema.after_lazy(class_based_type.(application_object, context)) do |authed| if authed application_object else err = GraphQL::UnauthorizedError.new( object: application_object, type: class_based_type, context: context, ) if self.respond_to?(:unauthorized_object) err.set_backtrace(caller) (err) else raise err end end end else application_object end end end end end |
#load_and_authorize_application_object(argument, id, context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
271 272 273 274 |
# File 'lib/graphql/schema/member/has_arguments.rb', line 271 def (argument, id, context) loaded_application_object = load_application_object(argument, id, context) (argument, id, context, loaded_application_object) end |
#load_application_object(argument, id, context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
263 264 265 266 267 268 269 |
# File 'lib/graphql/schema/member/has_arguments.rb', line 263 def load_application_object(argument, id, context) # See if any object can be found for this ID if id.nil? return nil end object_from_id(argument.loads, id, context) end |
#load_application_object_failed(err) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
320 321 322 |
# File 'lib/graphql/schema/member/has_arguments.rb', line 320 def load_application_object_failed(err) raise err end |
#object_from_id(type, id, context) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Look up the corresponding object for a provided ID. By default, it uses Relay-style GraphQL::Schema.object_from_id, override this to find objects another way.
259 260 261 |
# File 'lib/graphql/schema/member/has_arguments.rb', line 259 def object_from_id(type, id, context) context.schema.object_from_id(id, context) end |