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

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

Instance Method Summary collapse

Instance Method Details

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



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/search_object/plugin/graphql.rb', line 32

def option(name, options = {}, &block)
  type = options.fetch(:type) { raise MissingTypeDefinitionError, name }

  argument_options = options[:argument_options] || {}

  argument_options[:required] = options[:required] || false

  argument_options[:camelize] = options[:camelize] if options.include?(:camelize)
  argument_options[:default_value] = options[:default] if options.include?(:default)
  argument_options[:description] = options[:description] if options.include?(:description)
  argument_options[:deprecation_reason] = options[:deprecation_reason] if options.include?(:deprecation_reason)

  argument(name.to_s, type, **argument_options)

  options[:enum] = type.values.map { |value, enum_value| enum_value.value || value } if type.respond_to?(:values)

  super(name, options, &block)
end

#typesObject

NOTE(rstankov): This is removed in GraphQL 2.0.0



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

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