Class: HasHelpers::Resolvers::SearchQuery
- Inherits:
-
GraphQL::Schema::Resolver
- Object
- GraphQL::Schema::Resolver
- HasHelpers::Resolvers::SearchQuery
- Defined in:
- app/graphql/has_helpers/resolvers/search_query.rb
Instance Method Summary collapse
- #resolve(resources:, query: "", filter: nil, options: nil) ⇒ Object
- #search(resources_names, query, organization_id, filter, options) ⇒ Object
Instance Method Details
#resolve(resources:, query: "", filter: nil, options: nil) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/graphql/has_helpers/resolvers/search_query.rb', line 13 def resolve(resources:, query: "", filter: nil, options: nil) organization_id = context[:current_organization]&.id { results: search(resources, query, organization_id, filter, ) } end |
#search(resources_names, query, organization_id, filter, options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/graphql/has_helpers/resolvers/search_query.rb', line 22 def search(resources_names, query, organization_id, filter, ) # Add organization_id to options opts = (.respond_to?(:to_kwargs) ? .to_kwargs : .to_h).deep_symbolize_keys opts[:with] = (opts[:with] || {}).merge(organization_id: organization_id) # All rails search should be sql search, elasticsearch search's should go to elixir result = HasHelpers::Search::SqlSearch.new.exec_query( resource: resources_names, query: query, options: opts, filter: filter ) result.is_a?(Hash) ? result[:results] : (result || []) end |