module GraphqlRails::Model

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

Public Class Methods

included(base) click to toggle source
# File lib/graphql_rails/model.rb, line 36
def self.included(base)
  base.extend(ClassMethods)
end

Public Instance Methods

graphql_context() click to toggle source
# File lib/graphql_rails/model.rb, line 40
def graphql_context
  @graphql_context
end
graphql_context=(value) click to toggle source
# File lib/graphql_rails/model.rb, line 44
def graphql_context=(value)
  @graphql_context = value
end
with_graphql_context(graphql_context) { |self| ... } click to toggle source
# 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