Skip to content

Commit

Permalink
:as option doesn't play well with SearchObject
Browse files Browse the repository at this point in the history
  • Loading branch information
RStankov committed May 5, 2017
1 parent a1984b7 commit 22f2531
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/search_object/plugin/graphql.rb
Expand Up @@ -76,7 +76,6 @@ def build_argument(name, options)
argument.type = options.fetch(:type) { raise MissingTypeDefinitionError, name }
argument.default_value = options[:default] if options.key? :default
argument.description = options[:description] if options.key? :description
argument.as = options[:as] if options.key? :as
argument
end
end
Expand Down
22 changes: 20 additions & 2 deletions spec/search_object/plugin/graphql_spec.rb
Expand Up @@ -222,8 +222,26 @@ def define_search_class(&block)
expect { define_search_class { option :name } }.to raise_error described_class::MissingTypeDefinitionError
end

it 'accepts default type'
it 'accepts as'
it 'accepts default type' do
search_object = define_search_class do
scope { [] }

option(:id, type: types.String, default: 'default') do |_scope, value|
[Post.new(value)]
end
end

result = execute_query_on_schema('{ posts { id } }') do
field :posts, types[PostType], function: search_object
end

expect(result).to eq(
'data' => {
'posts' => [Post.new('default').to_json]
}
)
end

it 'accepts description'
end
end

0 comments on commit 22f2531

Please sign in to comment.