Module: GraphqlRails::Model
- Defined in:
- lib/graphql_rails/model.rb,
lib/graphql_rails/model/input.rb,
lib/graphql_rails/model/configurable.rb,
lib/graphql_rails/model/configuration.rb,
lib/graphql_rails/model/build_enum_type.rb,
lib/graphql_rails/model/build_connection_type.rb,
lib/graphql_rails/model/call_graphql_model_method.rb,
lib/graphql_rails/model/add_fields_to_graphql_type.rb,
lib/graphql_rails/model/find_or_build_graphql_type.rb,
lib/graphql_rails/model/find_or_build_graphql_input_type.rb,
lib/graphql_rails/model/find_or_build_graphql_type_class.rb,
lib/graphql_rails/model/build_connection_type/count_items.rb
Overview
this module allows to convert any ruby class in to graphql type object
usage: class YourModel
include GraphqlRails::Model
graphql do
attribute :id
attribute :title
end
end
YourModel.new.graphql_type # => type with [:id, :title] attributes
Defined Under Namespace
Modules: ClassMethods, Configurable Classes: AddFieldsToGraphqlType, BuildConnectionType, BuildEnumType, CallGraphqlModelMethod, Configuration, FindOrBuildGraphqlInputType, FindOrBuildGraphqlType, FindOrBuildGraphqlTypeClass, Input
Class Method Summary collapse
Instance Method Summary collapse
- #graphql_context ⇒ Object
- #graphql_context=(value) ⇒ Object
- #with_graphql_context(graphql_context) ⇒ Object
Class Method Details
.included(base) ⇒ Object
36 37 38 |
# File 'lib/graphql_rails/model.rb', line 36 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#graphql_context ⇒ Object
40 41 42 |
# File 'lib/graphql_rails/model.rb', line 40 def graphql_context @graphql_context end |
#graphql_context=(value) ⇒ Object
44 45 46 |
# File 'lib/graphql_rails/model.rb', line 44 def graphql_context=(value) @graphql_context = value end |
#with_graphql_context(graphql_context) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/graphql_rails/model.rb', line 48 def with_graphql_context(graphql_context) self.graphql_context = graphql_context yield(self) ensure self.graphql_context = nil end |