Class: Osso::GraphQL::Schema
- Inherits:
-
GraphQL::Schema
- Object
- GraphQL::Schema
- Osso::GraphQL::Schema
- Defined in:
- lib/osso/graphql/schema.rb
Class Method Summary collapse
- .id_from_object(object, _type_definition = nil, _query_ctx = nil) ⇒ Object
- .object_from_id(id, _query_ctx = nil) ⇒ Object
- .resolve_type(_type, obj, _ctx) ⇒ Object
- .unauthorized_object(error) ⇒ Object
Class Method Details
.id_from_object(object, _type_definition = nil, _query_ctx = nil) ⇒ Object
20 21 22 |
# File 'lib/osso/graphql/schema.rb', line 20 def self.id_from_object(object, _type_definition = nil, _query_ctx = nil) GraphQL::Schema::UniqueWithinType.encode(object.class.name, object.id) end |
.object_from_id(id, _query_ctx = nil) ⇒ Object
24 25 26 27 |
# File 'lib/osso/graphql/schema.rb', line 24 def self.object_from_id(id, _query_ctx = nil) class_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id) Object.const_get(class_name).find(item_id) end |
.resolve_type(_type, obj, _ctx) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/osso/graphql/schema.rb', line 29 def self.resolve_type(_type, obj, _ctx) case obj when Osso::Models::EnterpriseAccount Types::EnterpriseAccount when Osso::Models::IdentityProvider Types::IdentityProvider else raise("Unexpected object: #{obj}") end end |
.unauthorized_object(error) ⇒ Object
40 41 42 |
# File 'lib/osso/graphql/schema.rb', line 40 def self.(error) raise ::GraphQL::ExecutionError, "An object of type #{error.type.graphql_name} was hidden due to permissions" end |