class ActiveGraphQL::Model

Attributes

config[RW]

Public Class Methods

all() click to toggle source
# File lib/activegraphql/model.rb, line 40
def all
  build_fetcher(name.demodulize.underscore.pluralize.to_sym)
end
build_fetcher(action, params = nil) click to toggle source
# File lib/activegraphql/model.rb, line 52
def build_fetcher(action, params = nil)
  Fetcher.new(config: configurable_class.config,
              klass: self,
              action: action,
              params: params)
end
configurable_class() click to toggle source

Resolves the class who is extending from ActiveGraphql::Model.

This provides the capability for configuring inheritable classes with
specific configuration to the corresponding graphql service.
# File lib/activegraphql/model.rb, line 36
def configurable_class
  ancestors[ancestors.find_index(ActiveGraphQL::Model) - 1]
end
configure(config = {}) click to toggle source

This provides ability to configure the class inherited from here.

Also field classes will have the configuration.

Example:
  class BaseModelToMyService < ActiveGraphql::Model
    configure url: 'http://localhost:3000/graphql'
  end

  class ModelToMyService < BaseModelToMyService
  end

  BaseModelToMyService.config
  => { url: "http://localhost:3000/graphql" }

  ModelToMyService.url
  => { url: "http://localhost:3000/graphql" }
# File lib/activegraphql/model.rb, line 27
def configure(config = {})
  configurable_class.config ||= {}
  configurable_class.config.merge!(config)
end
find_by(conditions = {}) click to toggle source
# File lib/activegraphql/model.rb, line 48
def find_by(conditions = {})
  build_fetcher(name.demodulize.underscore.to_sym, conditions)
end
where(conditions = {}) click to toggle source
# File lib/activegraphql/model.rb, line 44
def where(conditions = {})
  build_fetcher(name.demodulize.underscore.pluralize.to_sym, conditions)
end