Skip to content

Commit

Permalink
Filter links for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
ztratify committed Dec 7, 2020
1 parent ac56701 commit 67c4dc0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/graphql/resolvers/search_links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ class LinkFilter < ::Types::BaseInputObject

# when "filter" is passed "apply_filter" would be called to narrow the scope
option :filter, type: LinkFilter, with: :apply_filter
option :first, type: Int, with: :apply_first
option :skip, type: Int, with: :apply_skip

def apply_first(scope, value)
scope.limit(value)
end

def apply_skip(scope, value)
scope.offset(value)
end

# apply_filter recursively loops through "OR" branches
def apply_filter(scope, value)
Expand Down

0 comments on commit 67c4dc0

Please sign in to comment.