Class: Ibrain::BaseSchema
- Inherits:
-
GraphQL::Schema
- Object
- GraphQL::Schema
- Ibrain::BaseSchema
- Defined in:
- app/graphql/ibrain/base_schema.rb
Class Method Summary collapse
- .field(*args, camelize: false, **kwargs, &block) ⇒ Object
-
.id_from_object(object, type_definition, query_ctx) ⇒ Object
Return a string UUID for ‘object`.
-
.object_from_id(id, query_ctx) ⇒ Object
Given a string UUID, find the object.
-
.resolve_type(_abstract_type, _obj, _ctx) ⇒ Object
Union and Interface Resolution.
Class Method Details
.field(*args, camelize: false, **kwargs, &block) ⇒ Object
42 43 44 45 46 47 48 |
# File 'app/graphql/ibrain/base_schema.rb', line 42 def self.field(*args, camelize: false, **kwargs, &block) # if camelize == false # # Also make a camelized field: # field(*args, camelize: false, **kwargs, &block) # end super end |
.id_from_object(object, type_definition, query_ctx) ⇒ Object
Return a string UUID for ‘object`
25 26 27 28 29 30 |
# File 'app/graphql/ibrain/base_schema.rb', line 25 def self.id_from_object(object, type_definition, query_ctx) # Here's a simple implementation which: # - joins the type name & object.id # - encodes it with base64: # GraphQL::Schema::UniqueWithinType.encode(type_definition.name, object.id) end |
.object_from_id(id, query_ctx) ⇒ Object
Given a string UUID, find the object
33 34 35 36 37 38 39 40 |
# File 'app/graphql/ibrain/base_schema.rb', line 33 def self.object_from_id(id, query_ctx) # For example, to decode the UUIDs generated above: # type_name, item_id = GraphQL::Schema::UniqueWithinType.decode(id) # # Then, based on `type_name` and `id` # find an object in your application # ... end |
.resolve_type(_abstract_type, _obj, _ctx) ⇒ Object
Union and Interface Resolution
16 17 18 19 20 |
# File 'app/graphql/ibrain/base_schema.rb', line 16 def self.resolve_type(_abstract_type, _obj, _ctx) # TODO: Implement this function # to return the correct object type for `obj` raise(GraphQL::RequiredImplementationMissingError) end |