Sha256: 6afc5d2403c1a043122474d0ef22c557183a2e5b439e115014040f5f3ec6ac15
Contents?: true
Size: 662 Bytes
Versions: 3
Compression:
Stored size: 662 Bytes
Contents
# frozen_string_literal: true require 'graphql' module GraphQL module Searchkick class SearchableExtension < GraphQL::Schema::FieldExtension def apply field.argument(:query, String, required: false, description: 'A search query') end def resolve(object:, arguments:, context:) next_args = arguments.dup result = yield(object, next_args) if defined?(ActiveRecord::Relation) && result.is_a?(ActiveRecord::Relation) result else model = options[:model_class] LazySearch.new(result, query: next_args[:query], model_class: model) end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems