JSONAPI-Resources / JSONAPI-Resources/jsonapi-resources

Feature Request: built in support for non where/in filtering

Open
#125 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Enhancement
Dominant language
Ruby
Stars
2.3k
Forks
546
PR merge metrics
No merged PRs in 30d

Description

Out of the box, JR takes this:

GET /users?filter[first_name]=Yehuda

and turns it into the equivalent of this:

User.where(:first_name => ["Yehuda"])

Although JSON API spec is agnostic about filter implementation, I propose introducing some naming patterns for "starts with", "ends with", "contains", and "not in" type attribute filters.

Examples

Get all users with a first_name that starts with "ye":

GET /users?filter[first_name^]=ye

Get all users with a first_name that ends with "huda":

GET /users?filter[first_name$]=huda

Get all users with a first_name that contains "hud":

GET /users?filter[first_name~]=hud

Get all users with a first_name that is NOT "Yehuda":

GET /users?filter[first_name!]=Yehuda

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Trace the existing handling of GET /users?filter[first_name] through the conversion to User.where. Review how filter names and values are parsed, then determine the expected behavior for starts-with, ends-with, contains, and not-equal filters. Done means the four proposed query forms are supported with matching coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
api, backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.