-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GraphQL: Add filtering on metadata to Samples and Attachments (#768)
* feat: add in jcont and jcont_key ransackers for jsonb columns, update sample and attachments graphql filters to include metadata_jcont and metadat_jcont_key filter * chore: introduce BaseRansackFilterInputObject which all FilterInputs are based off of * chore: add in tests for new metadata filters * chore: exclude jcont_all, jcont_any, jcont_key_all, jcont_key_any
- Loading branch information
Showing
11 changed files
with
184 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Types | ||
# Bsse Ransack Filter Input Object | ||
class BaseRansackFilterInputObject < BaseInputObject | ||
DEFAULT_EXCLUDED_ATTRIBUTES = %w[id metadata deleted_at].freeze | ||
JSONB_PREDICATE_KEYS = %w[jcont jcont_all jcont_any jcont_key jcont_key_all jcont_key_any].freeze | ||
|
||
def self.default_predicate_keys | ||
Ransack.predicates.keys.excluding(JSONB_PREDICATE_KEYS) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# frozen_string_literal: true | ||
|
||
module Arel | ||
module Predications # rubocop:disable Style/Documentation | ||
def contains_key(other) | ||
Arel::Nodes::InfixOperation.new(:'?', self, Arel::Nodes::Quoted.new(other)) | ||
end | ||
end | ||
end | ||
|
||
Ransack.configure do |config| | ||
config.add_predicate 'jcont', arel_predicate: 'contains', formatter: proc { |v| JSON.parse(v.to_s) } | ||
config.add_predicate 'jcont_key', arel_predicate: 'contains_key' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters