Module: SearchObject::Plugin::Graphql::ClassMethods

Defined in:
lib/search_object/plugin/graphql.rb

Instance Method Summary collapse

Instance Method Details

#argumentsObject



38
39
40
# File 'lib/search_object/plugin/graphql.rb', line 38

def arguments
  config[:args] ||= {}
end

#call(object, args, context) ⇒ Object

NOTE(rstankov): GraphQL::Function interface Documentation - rmosolgo.github.io/graphql-ruby/schema/code_reuse#functions



34
35
36
# File 'lib/search_object/plugin/graphql.rb', line 34

def call(object, args, context)
  new(filters: args.to_h, object: object, context: context).results
end

#complexity(value = :default) ⇒ Object



47
48
49
50
# File 'lib/search_object/plugin/graphql.rb', line 47

def complexity(value = :default)
  return config[:complexity] || 1 if value == :default
  config[:complexity] = value
end

#deprecation_reason(value = :default) ⇒ Object



57
58
59
60
# File 'lib/search_object/plugin/graphql.rb', line 57

def deprecation_reason(value = :default)
  return config[:deprecation_reason] if value == :default
  config[:deprecation_reason] = value
end

#description(value = :default) ⇒ Object



52
53
54
55
# File 'lib/search_object/plugin/graphql.rb', line 52

def description(value = :default)
  return config[:description] if value == :default
  config[:description] = value
end

#option(name, options = {}, &block) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/search_object/plugin/graphql.rb', line 19

def option(name, options = {}, &block)
  argument = Helper.build_argument(name, options)
  arguments[argument.name] = argument

  options[:enum] = argument.type.values.keys if argument.type.is_a? GraphQL::EnumType

  super(name, options, &block)
end

#type(value = :default, &block) ⇒ Object



42
43
44
45
# File 'lib/search_object/plugin/graphql.rb', line 42

def type(value = :default, &block)
  return config[:type] if value == :default && !block_given?
  config[:type] = block_given? ? GraphQL::ObjectType.define(&block) : value
end

#typesObject



28
29
30
# File 'lib/search_object/plugin/graphql.rb', line 28

def types
  GraphQL::Define::TypeDefiner.instance
end