Sha256: 0509a66f7f33912cff47a63b1c4e705e60b21ee5b295795052563663c100539b
Contents?: true
Size: 561 Bytes
Versions: 2
Compression:
Stored size: 561 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 query = next_args.delete(:query) result = yield(object, next_args) model = options[:model_class] LazySearch.new(result, query: query, model_class: model) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
graphql-searchkick-0.2.0 | lib/graphql/searchkick/searchable_extension.rb |
graphql-searchkick-0.1.0 | lib/graphql/searchkick/searchable_extension.rb |