Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support filter expressions in filter param #8

Closed
adamhenson opened this issue Jan 5, 2022 · 1 comment
Closed

Support filter expressions in filter param #8

adamhenson opened this issue Jan 5, 2022 · 1 comment

Comments

@adamhenson
Copy link
Contributor

Summary

Currently we accept a filter argument as an array of strings.

This is mistakenly prescriptive in that it generates a filter expression with commas (or operators). See filtering syntax.

For example, let's assume we want to get posts that are featured, but are not tagged as tutorial. Assuming the negation operator (-), one may naively come up with an argument like this: filter: ["featured:true", "tag:-tutorial"] (the outcome of not having any other choice).

filter: ["featured:true", "tag:-tutorial"] from our GraphQL query will actually generate a content API query param like so (this would be URI encoded of course):

?filter=featured:true,tag:-tutorial

This is problematic, because in filtering syntax, a comma is actually an "or" operator and our intention was for it to be an "and" like so:

?filter=featured:true+tag:-tutorial

Solution

Support both arrays or a string as a query argument. The array argument should work as it does today and a string argument should be taken literally (this will allow support for filtering syntax).

This support would allow an argument that looks like the below.

filter: "featured:true+tag:-tutorial"
@adamhenson
Copy link
Contributor Author

adamhenson commented Jan 5, 2022

Added a filterExpression argument to support this in 24eafff... used like so:

filterExpression: "featured:true+tag:-tutorial"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant