Skip to content

Commit

Permalink
✨Added advanced filtering to Dynamic Routing (#9757)
Browse files Browse the repository at this point in the history
refs #9601, refs #9742

- Upgraded NQL to 0.1.0
- The new version of NQL supports aliases e.g. `tag: tags.slug`, which makes it possible to define `filter=tag:support`
- Furthermore, this allows us to support advanced filtering like tag:[a,b]
- In dynamic routing, we use mingo via NQL which has a slightly different feature set to GQL in the API:
   - AND NOT, OR and other advanced logic combos DO work on joined tables
   - Counts are not yet supported
- The Dynamic Routing beta docs should describe that API filtering and Dynamic Routing filtering is different
  • Loading branch information
ErisDS authored and kirrg001 committed Aug 16, 2018
1 parent c39df00 commit 290f74f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
6 changes: 4 additions & 2 deletions core/server/services/url/UrlGenerator.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const _ = require('lodash'),
nql = require('@nexes/nql'),
debug = require('ghost-ignition').debug('services:url:generator'),
localUtils = require('./utils');
localUtils = require('./utils'),

aliases = {author: 'authors.slug', tags: 'tags.slug', tag: 'tags.slug', authors: 'authors.slug'};

class UrlGenerator {
constructor(router, queue, resources, urls, position) {
Expand All @@ -16,7 +18,7 @@ class UrlGenerator {
// CASE: routers can define custom filters, but not required.
if (this.router.getFilter()) {
this.filter = this.router.getFilter();
this.nql = nql(this.filter);
this.nql = nql(this.filter, {aliases});
debug('filter', this.filter);
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"cli": "^1.9.0"
},
"dependencies": {
"@nexes/nql": "0.0.1",
"@nexes/nql": "0.1.0",
"amperize": "0.3.7",
"analytics-node": "2.4.1",
"archiver": "1.3.0",
Expand Down
22 changes: 11 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
# yarn lockfile v1


"@nexes/mongo-knex@0.0.0":
version "0.0.0"
resolved "https://registry.yarnpkg.com/@nexes/mongo-knex/-/mongo-knex-0.0.0.tgz#7a44a7263d8830c8416b90ba3c963c2c722e7b72"
"@nexes/mongo-knex@0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@nexes/mongo-knex/-/mongo-knex-0.0.1.tgz#141c8ca380e95c1460fe2abcd777d7fd2bb14e8f"
dependencies:
lodash "^4.17.10"

"@nexes/nql-lang@0.0.0":
version "0.0.0"
resolved "https://registry.yarnpkg.com/@nexes/nql-lang/-/nql-lang-0.0.0.tgz#eb0fb807aea8aa64d3d0b454f3d1167af394f39a"

"@nexes/nql@0.0.1":
"@nexes/nql-lang@0.0.1":
version "0.0.1"
resolved "https://registry.yarnpkg.com/@nexes/nql/-/nql-0.0.1.tgz#e8f5e5352badeffd67e371f22bccd41fa0c20c24"
resolved "https://registry.yarnpkg.com/@nexes/nql-lang/-/nql-lang-0.0.1.tgz#a13c023873f9bc11b9e4e284449c6cfbeccc8011"

"@nexes/nql@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@nexes/nql/-/nql-0.1.0.tgz#b63614d5874bebb387b58d3f1b9fb9602115cf62"
dependencies:
"@nexes/mongo-knex" "0.0.0"
"@nexes/nql-lang" "0.0.0"
"@nexes/mongo-knex" "0.0.1"
"@nexes/nql-lang" "0.0.1"
mingo "2.2.2"

"@segment/loosely-validate-event@^1.1.2":
Expand Down

0 comments on commit 290f74f

Please sign in to comment.